home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-05-29 | 90.5 KB | 3,663 lines |
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/lib/Changelo,v
- retrieving revision 1.93
- diff -c -r1.93 Changelo
- *** 1.93 1993/05/21 12:52:46
- --- Changelo 1993/05/29 20:26:25
- ***************
- *** 3730,3732 ****
- --- 3730,3767 ----
- Fixed sign for retinf, and retzero.
-
- ---------------------------- Patchlevel 89 ---------------------------
- +
- + michal did a tremendous amount of job tracking down modf and
- + fixing the following. thanks michal.
- +
- + Wed May 26 20:35:34 1993 Michal Jaegermann (michal at smok)
- +
- + * fixed norm_df and norm_sf not to set errno when processing
- + legitimate zero argument
- + * fixed wrong error codes and made sure that future changes
- + in errno.h will be automatically reflected;
- + this involves changes in errbase.h and errno.h
- + * removed unused code from _divsf3.cpp
- + * corrected bug in setting sign of Inf in _truncdf.cpp
- + * made zeros returned from frexp and ldexp consistenly signed
- + (they were signed or unsigned, depending on a way they were
- + calculated)
- + * renamed _cmpdf2.s to _cmpdf2.cpp and _cmpsf2.s to _cmpsf2.cpp
- + and added preprocessor directives to split them into separate
- + objects while compiling (required change in mincl)
- + * replaced 68000 code for modf() with totally new, shorter and
- + much faster version
- + * added Olaf Flebbe fixes for sign of 0 in multiplication routines
- + * general code cleanup all over the place in floating point support
- + routines
- +
- + scanf.c:: ++jrb
- + fix bug reported by warwick, when "%Ns", the test for the end of
- + the %s loop was incorrect. (left off 1 char too soon).
- +
- + added some decls for non ansi platforms.
- +
- + use long double type only when __M68881__ not with soft float.
- + out soft float stuff knows nothing about long doubles.
- +
- + ---------------------------- Patchlevel 90 ---------------------------
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/lib/PatchLev.h,v
- retrieving revision 1.65
- diff -c -r1.65 PatchLev.h
- *** 1.65 1993/05/21 12:52:51
- --- PatchLev.h 1993/05/29 20:26:29
- ***************
- *** 1,5 ****
-
- ! #define PatchLevel "89"
-
- /*
- *
- --- 1,5 ----
-
- ! #define PatchLevel "90"
-
- /*
- *
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/lib/fscanf.c,v
- retrieving revision 1.9
- diff -c -r1.9 fscanf.c
- *** 1.9 1992/01/29 20:58:29
- --- fscanf.c 1993/05/29 20:26:32
- ***************
- *** 5,11 ****
- #include <compiler.h>
- #endif
-
- ! #ifdef sun
- # define fungetc ungetc
- #endif
-
- --- 5,11 ----
- #include <compiler.h>
- #endif
-
- ! #if defined(sun) || defined(__hpux)
- # define fungetc ungetc
- #endif
-
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/lib/mincl,v
- retrieving revision 1.27
- diff -c -r1.27 mincl
- *** 1.27 1993/05/21 12:52:54
- --- mincl 1993/05/29 20:26:34
- ***************
- *** 1,6 ****
- #
- # GCC specific stuff
- ! GLIB1 = _addsubd.o _addsubs.o _cmpdf2.o _cmpsf2.o _divdf3.o _divmods.o \
- _divsf3.o _extends.o _fixdfsi.o _fxunsd.o _fltsi.o \
- _muldf3.o _mulsf3.o _mulsi3.o _negdf2.o _negsf2.o _normdf.o _normsf.o \
- _truncdf.o _udivmod.o _umulsi3.o _fixsfsi.o _fltsisf.o _isnan.o
- --- 1,9 ----
- #
- # GCC specific stuff
- ! FCOMPD = _eqdf2.o _gtdf2.o _ledf2.o _gedf2.o _ltdf2.o
- ! FCOMPS = _eqsf2.o _gtsf2.o _lesf2.o _gesf2.o _ltsf2.o
- !
- ! GLIB1 = _addsubd.o _addsubs.o _divdf3.o _divmods.o \
- _divsf3.o _extends.o _fixdfsi.o _fxunsd.o _fltsi.o \
- _muldf3.o _mulsf3.o _mulsi3.o _negdf2.o _negsf2.o _normdf.o _normsf.o \
- _truncdf.o _udivmod.o _umulsi3.o _fixsfsi.o _fltsisf.o _isnan.o
- ***************
- *** 12,18 ****
- _caps_New.o _builtin_del.o _trampoline.o __main.o _ctor_list.o \
- _dtor_list.o _ffsdi2.o
-
- ! GCC= $(GLIB1) $(GLIB2) \
- ldexp.o frexp.o modf.o alloca.o setjmp.o osbind.o\
- linea.o alglobal.o sysvar.o gmon.o screen.o stksiz.o binmode.o \
- bblink.o defmode.o
- --- 15,21 ----
- _caps_New.o _builtin_del.o _trampoline.o __main.o _ctor_list.o \
- _dtor_list.o _ffsdi2.o
-
- ! GCC= $(GLIB1) $(GLIB2) $(FCOMPD) $(FCOMPS)\
- ldexp.o frexp.o modf.o alloca.o setjmp.o osbind.o\
- linea.o alglobal.o sysvar.o gmon.o screen.o stksiz.o binmode.o \
- bblink.o defmode.o
- ***************
- *** 86,91 ****
- --- 89,100 ----
- #
- # Assembler stuff that needs to be preprocessed by cpp
- #
- + $(FCOMPD): %.o: _cmpdf2.cpp
- + $(CC) $(PPFLAGS) -DL$* -c $< -o $@
- +
- + $(FCOMPS): %.o: _cmpsf2.cpp
- + $(CC) $(PPFLAGS) -DL$* -c $< -o $@
- +
- %.o : %.cpp
- $(CC) $(PPFLAGS) -c $<
-
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/lib/scanf.c,v
- retrieving revision 1.15
- diff -c -r1.15 scanf.c
- *** 1.15 1992/10/09 20:32:44
- --- scanf.c 1993/05/29 20:26:36
- ***************
- *** 39,44 ****
- --- 39,45 ----
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- + #include <compiler.h>
-
- /* the code assumes this definition, note: traditional <ctype> def
- * of tolower will break the code. Ansi def should be ok.
- ***************
- *** 70,75 ****
- --- 71,78 ----
- #define input_error() return( done < 1 ? EOF : done )
- #define memory_error() return((errno = ENOMEM), EOF)
-
- + __EXTERN long int strtol __PROTO((const char *nptr, char **endptr, int base));
- + __EXTERN double strtod __PROTO((const char *s, char **endptr));
-
- /* Read formatted input from S according to the format string
- FORMAT, using the argument list in ARG.
- ***************
- *** 110,116 ****
- --- 113,123 ----
- unsigned long int unum;
- #if FLOATS
- /* Floating-point holding variable. */
- + # ifdef __M68881__
- long double fp_num;
- + # else
- + double fp_num;
- + # endif
- #endif
- /* Character-buffer pointer. */
- register char *str;
- ***************
- *** 285,293 ****
- break;
- if (do_assign)
- *str++ = c;
- ! if (width > 0 && --width == 0)
- ! break;
- ! } while (inchar() != EOF);
-
- if (do_assign)
- {
- --- 292,298 ----
- break;
- if (do_assign)
- *str++ = c;
- ! } while ((inchar() != EOF) && ((width > 0) ? --width != 0 : 1));
-
- if (do_assign)
- {
- ***************
- *** 468,474 ****
- --- 473,483 ----
- if (do_assign)
- {
- if (is_long_double)
- + #ifdef __M68881__
- *va_arg(arg, long double *) = fp_num;
- + #else
- + *va_arg(arg, double *) = fp_num;
- + #endif
- else if (is_long)
- *va_arg(arg, double *) = (double) fp_num;
- else
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_addsubd.cpp,v
- retrieving revision 1.6
- diff -c -r1.6 _addsubd.cpp
- *** 1.6 1993/03/01 17:33:55
- --- _addsubd.cpp 1993/05/29 20:28:20
- ***************
- *** 10,15 ****
- --- 10,19 ----
- |
- | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
- | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
- + |
- + | Revision 1.3.5 michal 05-93 (ntomczak@vm.ucs.ualberta.ca)
- + | + code smoothing
- + |
- | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
- |
- | Revision 1.3.4 olaf 11-92 :
- ***************
- *** 23,30 ****
- |
- | Revision 1.3.3 olaf 11-92 :
- | + changed to get rid of rounding bits. a sticky register (d3) is
- ! | sufficient.
- ! |
- | Revision 1.3.2 olaf 10-92 :
- | + increased comparson by one again. (Dont understand, but it works)
- | + corrected negation of rounding bits and mantissa
- --- 27,34 ----
- |
- | Revision 1.3.3 olaf 11-92 :
- | + changed to get rid of rounding bits. a sticky register (d3) is
- ! | sufficient.
- ! |
- | Revision 1.3.2 olaf 10-92 :
- | + increased comparson by one again. (Dont understand, but it works)
- | + corrected negation of rounding bits and mantissa
- ***************
- *** 59,85 ****
- moveml d2-d7,sp@- | save registers
- moveml a0@,d4-d5/d6-d7 | d4-d5 = v, d6-d7 = u
-
- movel d6,d0 | d0 = u.exp
- swap d0
- ! movel d6,d2 | d2.h = u.sign
- ! movew d0,d2
- lsrw #4,d0
- - andw #0x07ff,d0 | kill sign bit
-
- movel d4,d1 | d1 = v.exp
- swap d1
- ! eorw d1,d2 | d2.l = u.sign ^ v.sign
- lsrw #4,d1
- - andw #0x07ff,d1 | kill sign bit
- -
- - andl #0x0fffff,d6 | remove exponent from u.mantissa
- - andl #0x0fffff,d4 | remove exponent from v.mantissa
- |
- | Now perform testing of NaN And infinities
- |
- ! cmpw #0x07ff,d0
- beq 0f
- ! cmpw #0x07ff,d1
- bne nospec
- bra 1f
- | first operand is special
- --- 63,90 ----
- moveml d2-d7,sp@- | save registers
- moveml a0@,d4-d5/d6-d7 | d4-d5 = v, d6-d7 = u
-
- + movel #0x0fffff,d3
- movel d6,d0 | d0 = u.exp
- + andl d3,d6 | remove exponent from u.mantissa
- + movel d0,d2 | d2.h = u.sign
- swap d0
- ! movew d0,d2 | d2.l = u.sign
- ! bclr #15,d0 | kill sign bit
- lsrw #4,d0
-
- movel d4,d1 | d1 = v.exp
- + andl d3,d4 | remove exponent from v.mantissa
- swap d1
- ! eorw d1,d2 | d2.l = u.sign ^ v.sign (in bit 15)
- ! bclr #15,d1 | kill sign bit
- lsrw #4,d1
- |
- | Now perform testing of NaN And infinities
- |
- ! movew #0x7ff,d3
- ! cmpw d3,d0
- beq 0f
- ! cmpw d3,d1
- bne nospec
- bra 1f
- | first operand is special
- ***************
- *** 88,100 ****
- beq bothspec
- |
- | u is special
- ! |
- movel d7,d0
- orl d6,d0
- bne retnan | arith with Nan gives always Nan
-
- movel a0@(8),d0 | copy infinity
- ! clrl d1
- bra return
- |
- | v is special
- --- 93,105 ----
- beq bothspec
- |
- | u is special
- ! |
- movel d7,d0
- orl d6,d0
- bne retnan | arith with Nan gives always Nan
-
- movel a0@(8),d0 | copy infinity
- ! moveq #0,d1
- bra return
- |
- | v is special
- ***************
- *** 103,109 ****
- orl d4,d0
- bne retnan
- movel a0@,d0
- ! clrl d1
- bra return
- |
- | u and v are both special
- --- 108,114 ----
- orl d4,d0
- bne retnan
- movel a0@,d0
- ! moveq #0,d1
- bra return
- |
- | u and v are both special
- ***************
- *** 113,156 ****
- orl d6,d0
- orl d5,d0
- orl d4,d0
- ! beq bothinf
- ! bra retnan
- |
- | Both are infinities Test if cancellation
- ! |
- bothinf:
- tstw d2
- ! bpl retinf
- |
- | return a quiet NaN
- |
- ! retnan: movel #0x7fffffff,d0
- ! moveql #-1,d1
- bra return
-
- ! retinf: movel #0x7ff00000,d0
- ! clrl d1
- ! tstl d2
- ! bpl return
- ! bchg #31,d0
- return: moveml sp@+,d2-d7
- rts
- ! |
- | Ok, no inifinty or Nan involved..
- |
- ! nospec: tstw d0 | check for zero exponent - no leading "1"
- ! beq 0f
- ! bset #20,d6 | restore implied leading "1"
- ! bra 1f
- ! 0: addw #1,d0 | "normalize" exponent
- 1:
- - tstw d1 | check for zero exponent - no leading "1"
- - beq 0f
- bset #20,d4 | restore implied leading "1"
- ! bra 1f
- ! 0: addw #1,d1 | "normalize" exponent
- 1:
- ! clrl d3 | init sticky register
- negw d1 | d1 = u.exp - v.exp
- addw d0,d1
- beq 5f | exponents are equal - no shifting neccessary
- --- 118,160 ----
- orl d6,d0
- orl d5,d0
- orl d4,d0
- ! bne retnan
- |
- | Both are infinities Test if cancellation
- ! |
- bothinf:
- tstw d2
- ! bpl retinf
- |
- | return a quiet NaN
- |
- ! retnan: moveql #-1,d1
- ! movel d1,d0
- ! bclr #31,d0 | 0x7fffffff -> d0
- bra return
-
- ! retinf: moveq #0,d1
- ! movel #0xffe00000,d0 | we will return #0xfff00000 or #0x7ff00000
- ! lslw #1,d2
- ! roxrl #1,d0 | shift in high bit as given by d2
- return: moveml sp@+,d2-d7
- rts
- ! |
- | Ok, no inifinty or Nan involved..
- |
- ! nospec: bset #20,d6 | restore implied leading "1"
- ! tstw d0 | check for zero exponent - no leading "1"
- ! bne 1f
- ! bclr #20,d6 | no implied leading "1", instead ...
- ! addw #1,d0 | "normalize" exponent
- 1:
- bset #20,d4 | restore implied leading "1"
- ! tstw d1 | check for zero exponent - no leading "1"
- ! bne 1f
- ! bclr #20,d4 | no implied leading "1", instead ...
- ! addw #1,d1 | "normalize" exponent
- 1:
- ! moveq #0,d3 | init sticky register
- negw d1 | d1 = u.exp - v.exp
- addw d0,d1
- beq 5f | exponents are equal - no shifting neccessary
- ***************
- *** 170,186 ****
- | most significant digit, while gaining an additional digit for
- | rounding.
- |
- ! moveql #1,d3
- 2: addl d7,d7
- addxl d6,d6
- subw #1,d0 | decrement exponent
- subw #1,d1 | decrement counter
- dbeq d3,2b
- ! clrl d3
- |
- | now shift other mantissa right as fast as possible (almost).
- |
- ! 3:
- cmpw #16,d1 | see if fast rotate possible
- blt 4f
- orw d5,d3 | set sticky word
- --- 174,190 ----
- | most significant digit, while gaining an additional digit for
- | rounding.
- |
- ! moveql #1,d3
- 2: addl d7,d7
- addxl d6,d6
- subw #1,d0 | decrement exponent
- subw #1,d1 | decrement counter
- dbeq d3,2b
- ! moveq #0,d3
- |
- | now shift other mantissa right as fast as possible (almost).
- |
- ! 3:
- cmpw #16,d1 | see if fast rotate possible
- blt 4f
- orw d5,d3 | set sticky word
- ***************
- *** 193,203 ****
-
- 0: moveb d5,d2 | use d2.b as scratch
- andb #1,d2 | test if 1 is shifted out
- ! orb d2,d3 | and put it in sticky
- lsrl #1,d4 | shift v.mant right the rest of the way
- roxrl #1,d5 | to line it up with u.mant
- 4: dbra d1,0b | loop
- !
- 5:
- tstw d2 | are the signs equal ?
- bpl 6f | yes, no negate necessary
- --- 197,207 ----
-
- 0: moveb d5,d2 | use d2.b as scratch
- andb #1,d2 | test if 1 is shifted out
- ! orb d2,d3 | and put it in sticky
- lsrl #1,d4 | shift v.mant right the rest of the way
- roxrl #1,d5 | to line it up with u.mant
- 4: dbra d1,0b | loop
- !
- 5:
- tstw d2 | are the signs equal ?
- bpl 6f | yes, no negate necessary
- ***************
- *** 205,218 ****
- | negate secand mantissa. One has to check the sticky word in order
- | to correct the twos complement.
- |
- ! tstw d3 |
- beq 9f | No cerrection necessary
- ! clrl d1
- addql #1,d5
- addxl d1,d4
- 9: negl d5
- negxl d4
- !
- 6:
- addl d5,d7 | u.mant = u.mant + v.mant
- addxl d4,d6
- --- 209,222 ----
- | negate secand mantissa. One has to check the sticky word in order
- | to correct the twos complement.
- |
- ! tstw d3 |
- beq 9f | No cerrection necessary
- ! moveq #0,d1
- addql #1,d5
- addxl d1,d4
- 9: negl d5
- negxl d4
- !
- 6:
- addl d5,d7 | u.mant = u.mant + v.mant
- addxl d4,d6
- ***************
- *** 226,232 ****
- 7:
- movel d6,d4 | move result for normalization
- movel d7,d5
- ! clrl d1
- tstl d3
- beq 8f
- moveql #-1,d1
- --- 230,236 ----
- 7:
- movel d6,d4 | move result for normalization
- movel d7,d5
- ! moveq #0,d1
- tstl d3
- beq 8f
- moveql #-1,d1
- ***************
- *** 267,278 ****
- lea 0xfffffa50:w,a0
- movew #0x5400,a0@(comm) | load first argument to fp0
- cmpiw #0x8900,a0@(resp) | check
- ! movel a7@(4),a0@
- ! movel a7@(8),a0@
- movew #0x5428,a0@(comm)
- .long 0x0c688900, 0xfff067f8
- ! movel a7@(12),a0@
- ! movel a7@(16),a0@
- movew #0x7400,a0@(comm) | result to d0/d1
- .long 0x0c688900, 0xfff067f8
- movel a0@,d0
- --- 271,282 ----
- lea 0xfffffa50:w,a0
- movew #0x5400,a0@(comm) | load first argument to fp0
- cmpiw #0x8900,a0@(resp) | check
- ! movel sp@(4),a0@
- ! movel sp@(8),a0@
- movew #0x5428,a0@(comm)
- .long 0x0c688900, 0xfff067f8
- ! movel sp@(12),a0@
- ! movel sp@(16),a0@
- movew #0x7400,a0@(comm) | result to d0/d1
- .long 0x0c688900, 0xfff067f8
- movel a0@,d0
- ***************
- *** 284,295 ****
- lea 0xfffffa50:w,a0
- movew #0x5400,a0@(comm) | load fp0
- cmpiw #0x8900,a0@(resp) | got it?
- ! movel a7@(4),a0@ | take a hi from stack to FPU
- ! movel a7@(8),a0@ | take a lo from stack to FPU
- movew #0x5422,a0@(comm) | add second arg to fp0
- .long 0x0c688900, 0xfff067f8
- ! movel a7@(12),a0@ | move b hi from stack to FPU
- ! movel a7@(16),a0@ | move b lo from stack to FPU
- movew #0x7400,a0@(comm) | result to d0/d1
- .long 0x0c688900, 0xfff067f8
- movel a0@,d0 | download result
- --- 288,299 ----
- lea 0xfffffa50:w,a0
- movew #0x5400,a0@(comm) | load fp0
- cmpiw #0x8900,a0@(resp) | got it?
- ! movel sp@(4),a0@ | take a hi from stack to FPU
- ! movel sp@(8),a0@ | take a lo from stack to FPU
- movew #0x5422,a0@(comm) | add second arg to fp0
- .long 0x0c688900, 0xfff067f8
- ! movel sp@(12),a0@ | move b hi from stack to FPU
- ! movel sp@(16),a0@ | move b lo from stack to FPU
- movew #0x7400,a0@(comm) | result to d0/d1
- .long 0x0c688900, 0xfff067f8
- movel a0@,d0 | download result
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_addsubs.cpp,v
- retrieving revision 1.6
- diff -c -r1.6 _addsubs.cpp
- *** 1.6 1993/03/01 17:33:57
- --- _addsubs.cpp 1993/05/29 20:28:21
- ***************
- *** 10,15 ****
- --- 10,19 ----
- |
- | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
- | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
- + |
- + | Revision 1.3.5 michal 05-93 (ntomczak@vm.ucs.ualberta.ca)
- + | + code smoothing
- + |
- | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
- |
- | Revision 1.3.4 olaf 11-92 :
- ***************
- *** 61,88 ****
- moveml d2-d5,sp@- | save registers
- moveml a0@,d4/d5 | d4 = v, d5 = u
-
- movel d5,d0 | d0 = u.exp
- - swap d0
- movel d5,d2 | d2.h = u.sign
- ! movew d0,d2
- lsrw #7,d0
- - andw #0xff,d0 | kill sign bit (exponent is 8 bits)
-
- movel d4,d1 | d1 = v.exp
- swap d1
- ! eorw d1,d2 | d2.l = u.sign ^ v.sign
- lsrw #7,d1
- - andw #0xff,d1 | kill sign bit (exponent is 8 bits)
- -
- - andl #0x7fffff,d5 | remove exponent from mantissa
- - andl #0x7fffff,d4 | remove exponent from mantissa
- |
- | Now perform testing of NaN And infinities
- |
- ! cmpb #0xff,d0
- beq 0f
- ! cmpb #0xff,d1
- ! bne nospec
- bra 1f
- | first operand is special
- |
- --- 65,93 ----
- moveml d2-d5,sp@- | save registers
- moveml a0@,d4/d5 | d4 = v, d5 = u
-
- + movel #0x7fffff,d3
- movel d5,d0 | d0 = u.exp
- movel d5,d2 | d2.h = u.sign
- ! swap d0
- ! movew d0,d2 | d2 = u.sign
- ! andl d3,d5 | remove exponent from u.mantissa
- ! bclr #15,d0 | kill sign bit
- lsrw #7,d0
-
- movel d4,d1 | d1 = v.exp
- + andl d3,d4 | remove exponent from v.mantissa
- swap d1
- ! eorw d1,d2 | d2 = u.sign ^ v.sign (in bit 15)
- ! bclr #15,d1 | kill sign bit
- lsrw #7,d1
- |
- | Now perform testing of NaN And infinities
- |
- ! moveq #-1,d3
- ! cmpb d3,d0
- beq 0f
- ! cmpb d3,d1
- ! bne nospec
- bra 1f
- | first operand is special
- |
- ***************
- *** 90,100 ****
- beq bothspec
- |
- | u is special
- ! |
- tstl d5
- bne retnan | arith with Nan gives always Nan
-
- ! movel a0@(4),d0 | copy infinity
- bra return
- |
- | v is special
- --- 95,105 ----
- beq bothspec
- |
- | u is special
- ! |
- tstl d5
- bne retnan | arith with Nan gives always Nan
-
- ! movel a0@(4),d0 | copy infinity with its sign
- bra return
- |
- | v is special
- ***************
- *** 109,150 ****
- bothspec:
- movel d5,d0
- orl d4,d0
- ! beq bothinf
- ! bra retnan
- |
- | Both are infinities Test if cancellation
- ! |
- bothinf:
- tstw d2
- ! bpl retinf
- |
- | return a quiet NaN
- |
- ! retnan: movel #0x7fffffff,d0
- bra return
-
- ! retinf: movel #0x7f800000,d0
- ! tstl d2
- ! bpl return
- ! bchg #31,d0
- return: moveml sp@+,d2-d5
- rts
- ! |
- | Ok, no inifinty or Nan involved..
- |
- ! nospec: tstw d0 | check for zero exponent - no leading "1"
- ! beq 0f
- ! bset #23,d5 | restore implied leading "1"
- ! bra 1f
- ! 0: addw #1,d0 | "normalize" exponent
- 1:
- - tstw d1 | check for zero exponent - no leading "1"
- - beq 0f
- bset #23,d4 | restore implied leading "1"
- ! bra 1f
- ! 0: addw #1,d1 | "normalize" exponent
- 1:
- ! clrl d3 | (put initial zero rounding bits in d3)
- negw d1 | d1 = u.exp - v.exp
- addw d0,d1
- beq 5f | exponents are equal - no shifting neccessary
- --- 114,154 ----
- bothspec:
- movel d5,d0
- orl d4,d0
- ! bne retnan
- |
- | Both are infinities Test if cancellation
- ! |
- bothinf:
- tstw d2
- ! bpl retinf
- |
- | return a quiet NaN
- |
- ! retnan: moveql #-1,d0
- ! lsrl #1,d0 | 0x7fffffff -> d0
- bra return
-
- ! retinf: movel #0xff000000,d0 | we will return #0xff800000 or #0x7f800000
- ! lslw #1,d2
- ! roxrl #1,d0 | shift in high bit as given by d2
- return: moveml sp@+,d2-d5
- rts
- ! |
- | Ok, no inifinty or Nan involved..
- |
- ! nospec: bset #23,d5 | restore implied leading "1"
- ! tstw d0 | check for zero exponent - no leading "1"
- ! bne 1f
- ! bclr #23,d5 | remove it
- ! addqw #1,d0 | "normalize" exponent
- 1:
- bset #23,d4 | restore implied leading "1"
- ! tstw d1 | check for zero exponent - no leading "1"
- ! bne 1f
- ! bclr #23,d4 | remove it
- ! addqw #1,d1 | "normalize" exponent
- 1:
- ! moveq #0,d3 | (put initial zero rounding bits in d3)
- negw d1 | d1 = u.exp - v.exp
- addw d0,d1
- beq 5f | exponents are equal - no shifting neccessary
- ***************
- *** 163,174 ****
- | most significant digit, while gaining an additional digit for
- | rounding.
- |
- ! moveql #1,d3
- 2: addl d5,d5
- ! subw #1,d0 | decrement exponent
- ! subw #1,d1 | done shifting altogether ?
- dbeq d3,2b | loop if still can shift u.mant more
- ! clrl d3
-
- cmpw #16,d1 | see if fast rotate possible
- blt 4f
- --- 167,178 ----
- | most significant digit, while gaining an additional digit for
- | rounding.
- |
- ! moveql #1,d3
- 2: addl d5,d5
- ! subqw #1,d0 | decrement exponent
- ! subqw #1,d1 | done shifting altogether ?
- dbeq d3,2b | loop if still can shift u.mant more
- ! moveq #0,d3
-
- cmpw #16,d1 | see if fast rotate possible
- blt 4f
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_divdf3.cpp,v
- retrieving revision 1.6
- diff -c -r1.6 _divdf3.cpp
- *** 1.6 1993/05/21 12:55:07
- --- _divdf3.cpp 1993/05/29 20:28:23
- ***************
- *** 23,34 ****
-
- pea pc@(LC0)
- pea Stderr
- ! jbsr _fprintf |
- ! addql #8,a7 |
- ! | set _errno to ERANGE
- ! moveq #ERANGE,d0
- Emove d0,Errno
- ! moveml __infinitydf,d0-d1 | return signed infinity
- btst #31,a7@(4) | transfer sign of dividend
- beq clear | (mjr++)
- bset #31,d0 |
- --- 23,34 ----
-
- pea pc@(LC0)
- pea Stderr
- ! jbsr _fprintf
- ! addql #8,a7
- !
- ! moveq #Erange,d0 | set _errno to ERANGE
- Emove d0,Errno
- ! moveml __infinitydf,d0-d1 | return signed infinity
- btst #31,a7@(4) | transfer sign of dividend
- beq clear | (mjr++)
- bset #31,d0 |
- ***************
- *** 44,53 ****
- | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
- | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
- |
- | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
- |
- | Revision 1.2.3 olaf 4-93
- ! | + Fixed sign for retinf, and retzero: it is in d2.w
- |
- | Revision 1.2.2 olaf 12-92
- | + added support for NaN and Infinites
- --- 44,57 ----
- | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
- | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
- |
- + | Revision 1.2.4 michal 05-93 (ntomczak@vm.ucs.ualberta.ca)
- + | + resynchro with errno codes
- + | + code smoothing
- + |
- | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
- |
- | Revision 1.2.3 olaf 4-93
- ! | + Fixed sign for retinf, and retzero: it is in d2.w
- |
- | Revision 1.2.2 olaf 12-92
- | + added support for NaN and Infinites
- ***************
- *** 73,98 ****
- moveml d2-d7,sp@- | save registers
- moveml a0@,d4-d5/d6-d7 | d4-d5 = u, d6-d7 = v
-
- movel d4,d0 | d0 = u.exp
- swap d0
- movew d0,d2 | d2 = u.sign
- lsrw #4,d0
- - andw #0x07ff,d0 | kill sign bit
-
- movel d6,d1 | d1 = v.exp
- swap d1
- eorw d1,d2 | d2 = u.sign ^ v.sign (in bit 15)
- lsrw #4,d1
- - andw #0x07ff,d1 | kill sign bit
- -
- - andl #0x0fffff,d4 | remove exponent from u.mantissa
- - andl #0x0fffff,d6 | remove exponent from v.mantissa
- |
- |
- |
- ! cmpw #0x7ff,d0
- beq 0f |u == NaN || u== Inf
- ! cmpw #0x7ff,d1
- beq 1f | v == NaN || v == Inf
- tstw d0
- bne 3f | u not zero nor denorm
- --- 77,103 ----
- moveml d2-d7,sp@- | save registers
- moveml a0@,d4-d5/d6-d7 | d4-d5 = u, d6-d7 = v
-
- + movel #0x0fffff,d3
- movel d4,d0 | d0 = u.exp
- + andl d3,d4 | remove exponent from u.mantissa
- swap d0
- movew d0,d2 | d2 = u.sign
- + bclr #15,d0 | kill sign bit
- lsrw #4,d0
-
- movel d6,d1 | d1 = v.exp
- + andl d3,d6 | remove exponent from v.mantissa
- swap d1
- eorw d1,d2 | d2 = u.sign ^ v.sign (in bit 15)
- + bclr #15,d1 | kill sign bit
- lsrw #4,d1
- |
- |
- |
- ! movew #0x7ff,d3
- ! cmpw d3,d0
- beq 0f |u == NaN || u== Inf
- ! cmpw d3,d1
- beq 1f | v == NaN || v == Inf
- tstw d0
- bne 3f | u not zero nor denorm
- ***************
- *** 107,117 ****
- orl d6,d3
- bne nospec
- bra retinf | x/0 -> +/- Inf
- !
- 0: orl d5,d4 | u == NaN ?
- bne retnan | NaN/ x
- ! cmpw #0x7ff,d1
- ! beq retnan | Inf/Inf or Inf/NaN
- bra retinf | Inf/x | x != Inf && x != NaN
-
- 1: orl d7,d6
- --- 112,122 ----
- orl d6,d3
- bne nospec
- bra retinf | x/0 -> +/- Inf
- !
- 0: orl d5,d4 | u == NaN ?
- bne retnan | NaN/ x
- ! cmpw #0x7ff,d1
- ! beq retnan | Inf/Inf or Inf/NaN
- bra retinf | Inf/x | x != Inf && x != NaN
-
- 1: orl d7,d6
- ***************
- *** 121,168 ****
- 2: tstw d1
- bne retzero | 0/x ->+/- 0
- orl d5,d4
- ! bne retzero | 0/x
- bra retnan | 0/0
- |
- | Return Infinity with correct sign
- ! |
- ! retinf: clrl d1
- ! tstw d2
- ! bpl 0f
- ! movel #0xfff00000,d0
- return: moveml sp@+,d2-d7
- rts
- -
- - 0: movel #0x7ff00000,d0
- - bra return
- |
- | Return NaN
- |
- ! retnan: movel #0x7fffffff,d0
- ! moveql #-1,d1
- bra return
- |
- | Return correct signed zero
- |
- ! retzero:clrl d0 | zero destination
- ! clrl d1
- ! tstw d2
- ! bge return
- ! bset #31,d0
- bra return
- |
- | End of special handling
- ! |
- ! nospec: tstw d0 | check for zero exponent - no leading "1"
- ! beq 0f
- ! bset #20,d4 | restore implied leading "1"
- ! bra 1f
- ! 0: addw #1,d0 | "normalize" exponent
- !
- ! 1: tstw d1 | check for zero exponent - no leading "1"
- ! beq 0f
- ! bset #20,d6 | restore implied leading "1"
- ! bra 1f
- 0: addw #1,d1 | "normalize" exponent
-
- 1: movew d2,a0 | save sign
- --- 126,170 ----
- 2: tstw d1
- bne retzero | 0/x ->+/- 0
- orl d5,d4
- ! bne retzero | 0/x
- bra retnan | 0/0
- |
- | Return Infinity with correct sign
- ! |
- ! retinf: moveq #0,d1
- ! movel #0xffe00000,d0
- ! lslw #1,d2
- ! roxrl #1,d0 | shift in high bit as given by d2
- return: moveml sp@+,d2-d7
- rts
- |
- | Return NaN
- |
- ! retnan: moveql #-1,d1
- ! movel d1,d0
- ! bclr #31,d0 | 0x7fffffff -> d0
- bra return
- |
- | Return correct signed zero
- |
- ! retzero:moveq #0,d0 | zero destination
- ! movel d0,d1
- ! lslw #1,d2 | we need an extension bit
- ! roxrl #1,d0
- bra return
- |
- | End of special handling
- ! |
- ! nospec: bset #20,d4 | restore implied leading "1"
- ! tstw d0 | check for zero exponent - no leading "1"
- ! bne 1f
- ! bclr #20,d4 | remove it
- ! addw #1,d0 | "normalize" exponent
- !
- ! 1: bset #20,d6 | restore implied leading "1"
- ! tstw d1 | check for zero exponent - no leading "1"
- ! bne 1f
- ! bclr #20,d6 | remove it
- 0: addw #1,d1 | "normalize" exponent
-
- 1: movew d2,a0 | save sign
- ***************
- *** 172,179 ****
- addw #66,d0 | add loop offset, +2 for extra rounding bits
- | for denormalized numbers (2 implied by dbra)
- movew #24,d1 | bit number for "implied" pos (+4 for rounding)
- ! movel #-1,d2 | zero the quotient
- ! movel #-1,d3 | (for speed it is a one''s complement)
- subl d7,d5 | initial subtraction,
- subxl d6,d4 | u = u - v
- 2:
- --- 174,181 ----
- addw #66,d0 | add loop offset, +2 for extra rounding bits
- | for denormalized numbers (2 implied by dbra)
- movew #24,d1 | bit number for "implied" pos (+4 for rounding)
- ! moveq #-1,d2 | zero the quotient
- ! moveq #-1,d3 | (for speed it is a one''s complement)
- subl d7,d5 | initial subtraction,
- subxl d6,d4 | u = u - v
- 2:
- ***************
- *** 196,208 ****
- addl d7,d5 | add (restore)
- addxl d6,d4 | u = u + v
- dbra d0,2b | give up if result is denormalized
- ! 5: subw #2,d0 | remove rounding offset for denormalized nums
- notl d2 | invert quotient to get it right
- notl d3
-
- movel d5,d1
- orl d4,d1 | check for exact result
- ! beq 1f
- moveql #-1,d1 | Set rounding bits for tie case
- 1: movel d2,d4 | save quotient mantissa
- movel d3,d5
- --- 198,210 ----
- addl d7,d5 | add (restore)
- addxl d6,d4 | u = u + v
- dbra d0,2b | give up if result is denormalized
- ! 5: subqw #2,d0 | remove rounding offset for denormalized nums
- notl d2 | invert quotient to get it right
- notl d3
-
- movel d5,d1
- orl d4,d1 | check for exact result
- ! beq 1f
- moveql #-1,d1 | Set rounding bits for tie case
- 1: movel d2,d4 | save quotient mantissa
- movel d3,d5
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_divmods.s,v
- retrieving revision 1.3
- diff -c -r1.3 _divmods.s
- *** 1.3 1992/11/24 04:14:46
- --- _divmods.s 1993/05/29 20:28:24
- ***************
- *** 62,68 ****
- cmpl d2,d0 | compare with divisor
- bcs 0f
- subl d2,d0 | big enough, subtract
- ! addw #1,d1 | and note bit into result
- 0:
- dbra d3,3b
- exg d0,d1 | put quotient and remainder in their registers
- --- 62,68 ----
- cmpl d2,d0 | compare with divisor
- bcs 0f
- subl d2,d0 | big enough, subtract
- ! addqw #1,d1 | and note bit into result
- 0:
- dbra d3,3b
- exg d0,d1 | put quotient and remainder in their registers
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_divsf3.cpp,v
- retrieving revision 1.6
- diff -c -r1.6 _divsf3.cpp
- *** 1.6 1993/05/21 12:55:08
- --- _divsf3.cpp 1993/05/29 20:28:26
- ***************
- *** 18,38 ****
- ___divsf3:
-
- #ifdef ERROR_CHECK
- ! tstl a7@(8) | check if divisor is 0
- bne no_exception
-
- pea pc@(LC0)
- pea Stderr
- ! jbsr _fprintf |
- ! addql #8,a7 |
- ! | set _errno to ERANGE
- ! moveq #ERANGE,d0
- Emove d0,Errno
- ! movel __infinitysf,d0 | return signed infinity
- ! btst #31,a7@(4) | transfer sign of dividend
- beq clear | (mjr++)
- bset #31,d0 |
- - rts |
- clear: |
- rts
-
- --- 18,37 ----
- ___divsf3:
-
- #ifdef ERROR_CHECK
- ! tstl sp@(8) | check if divisor is 0
- bne no_exception
-
- pea pc@(LC0)
- pea Stderr
- ! jbsr _fprintf
- ! addql #8,sp
- !
- ! moveq #Erange,d0 | set _errno to ERANGE
- Emove d0,Errno
- ! movel __infinitysf,d0 | return signed infinity
- ! btst #31,sp@(4) | transfer sign of dividend
- beq clear | (mjr++)
- bset #31,d0 |
- clear: |
- rts
-
- ***************
- *** 43,48 ****
- --- 42,53 ----
- |
- | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
- | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
- + | Revision 1.2.4 michal 05-93 (ntomczak@vm.ucs.ualberta.ca)
- + | + resynchro with errno codes
- + | + code smoothing
- + | + removed extra code 'retz:' and 'divz:'; these cases are
- + | going back through 'retzero:' and 'retinf:'
- + |
- | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
- |
- | Revision 1.2.3 olaf 5-93
- ***************
- *** 72,103 ****
- moveml d2-d5,sp@- | save registers
- moveml a0@,d4/d5 | d4 = u, d5 = v
-
- movel d4,d0 | d0 = u.exp
- swap d0
- movew d0,d2 | d2 = u.sign
- lsrw #7,d0
- - andw #0xff,d0 | kill sign bit
-
- movel d5,d1 | d1 = v.exp
- swap d1
- eorw d1,d2 | d2 = u.sign ^ v.sign (in bit 15)
- lsrw #7,d1
- - andw #0xff,d1 | kill sign bit
- -
- - andl #0x7fffff,d4 | remove exponent from u.mantissa
- - andl #0x7fffff,d5 | remove exponent from v.mantissa
- |
- |
- |
- ! cmpb #0xff,d0
- beq 0f |u == NaN || u== Inf
- ! cmpb #0xff,d1
- beq 1f | v == NaN || v == Inf
- tstb d0
- bne 3f | u not zero nor denorm
- tstl d4
- beq 2f | 0/ ?
- !
- 3: tstw d1
- bne nospec
-
- --- 77,109 ----
- moveml d2-d5,sp@- | save registers
- moveml a0@,d4/d5 | d4 = u, d5 = v
-
- + movel #0x7fffff,d3
- movel d4,d0 | d0 = u.exp
- + andl d3,d4 | remove exponent from u.mantissa
- swap d0
- movew d0,d2 | d2 = u.sign
- + bclr #15,d0 | kill sign bit
- lsrw #7,d0
-
- movel d5,d1 | d1 = v.exp
- + andl d3,d5 | remove exponent from v.mantissa
- swap d1
- eorw d1,d2 | d2 = u.sign ^ v.sign (in bit 15)
- + bclr #15,d1 | kill sign bit
- lsrw #7,d1
- |
- |
- |
- ! moveq #-1,d3
- ! cmpb d3,d0 | comparison with #0xff
- beq 0f |u == NaN || u== Inf
- ! cmpb d3,d1
- beq 1f | v == NaN || v == Inf
- tstb d0
- bne 3f | u not zero nor denorm
- tstl d4
- beq 2f | 0/ ?
- !
- 3: tstw d1
- bne nospec
-
- ***************
- *** 107,114 ****
-
- 0: tstl d4 | u == NaN ?
- bne retnan | NaN/ x
- ! cmpb #0xff,d1
- ! beq retnan | Inf/Inf or Inf/NaN
- bra retinf | Inf/x | x != Inf && x != NaN
-
- 1: tstl d5
- --- 113,120 ----
-
- 0: tstl d4 | u == NaN ?
- bne retnan | NaN/ x
- ! cmpb d3,d1
- ! beq retnan | Inf/Inf or Inf/NaN
- bra retinf | Inf/x | x != Inf && x != NaN
-
- 1: tstl d5
- ***************
- *** 118,177 ****
- 2: tstw d1
- bne retzero | 0/x ->+/- 0
- tstl d4
- ! bne retzero | 0/x
- bra retnan | 0/0
- |
- | Return Infinity with correct sign
- ! |
- ! retinf: tstw d2
- ! bpl 0f
- ! movel #0xff800000,d0
- return: moveml sp@+,d2-d5
- rts
- -
- - 0: movel #0x7f800000,d0
- - bra return
- |
- | Return NaN
- |
- ! retnan: movel #0x7fffffff,d0
- bra return
- |
- | Return correct signed zero
- |
- ! retzero:clrl d0 | zero destination
- ! tstw d2
- ! bge return
- ! bset #31,d0
- bra return
- |
- | End of special handling
- ! |
- ! nospec: tstw d0 | check for zero exponent - no leading "1"
- ! beq 0f
- ! bset #23,d4 | restore implied leading "1"
- ! bra 1f
- ! 0: addw #1,d0 | "normalize" exponent
- 1:
- - # ifndef ERROR_CHECK
- tstl d4
- ! beq retz | dividing zero
- ! # endif ERROR_CHECK
-
- - tstw d1 | check for zero exponent - no leading "1"
- - beq 0f
- bset #23,d5 | restore implied leading "1"
- ! bra 1f
- ! 0: addw #1,d1 | "normalize" exponent
- ! 1: tstl d5
- ! beq divz | divide by zero
-
- subw d1,d0 | subtract exponents,
- addw #BIAS4-8+1,d0 | add bias back in, account for shift
- addw #34,d0 | add loop offset, +2 for extra rounding bits
- | for denormalized numbers (2 implied by dbra)
- movew #27,d1 | bit number for "implied" pos (+4 for rounding)
- ! movel #-1,d3 | zero quotient (for speed a one''s complement)
- subl d5,d4 | initial subtraction, u = u - v
- 2:
- btst d1,d3 | divide until 1 in implied position
- --- 124,181 ----
- 2: tstw d1
- bne retzero | 0/x ->+/- 0
- tstl d4
- ! bne retzero | 0/x
- bra retnan | 0/0
- |
- | Return Infinity with correct sign
- ! |
- ! retinf: movel #0xff000000,d0
- ! lslw #1,d2
- ! roxrl #1,d0 | shift in high bit as given by d2
- return: moveml sp@+,d2-d5
- rts
- |
- | Return NaN
- |
- ! retnan: movel d3,d0 | d3 contains 0xffffffff
- ! bclr #31,d0
- bra return
- |
- | Return correct signed zero
- |
- ! retzero:moveq #0,d0 | zero destination
- ! lslw #1,d2 | set X bit accordingly
- ! roxrl #1,d0
- bra return
- |
- | End of special handling
- ! |
- ! nospec: bset #23,d4 | restore implied leading "1"
- ! tstw d0 | check for zero exponent - no leading "1"
- ! bne 1f
- ! bclr #23,d4 | remove it
- ! addw #1,d0 | "normalize" exponent
- 1:
- tstl d4
- ! beq retzero | dividing zero
-
- bset #23,d5 | restore implied leading "1"
- ! tstw d1 | check for zero exponent - no leading "1"
- ! bne 1f
- ! bclr #23,d5 | remove it
- ! addw #1,d1 | "normalize" exponent
- ! 1:
- ! # ifndef ERROR_CHECK
- ! tstl d5
- ! beq retinf | divide by zero
- ! # endif ERROR_CHECK
-
- subw d1,d0 | subtract exponents,
- addw #BIAS4-8+1,d0 | add bias back in, account for shift
- addw #34,d0 | add loop offset, +2 for extra rounding bits
- | for denormalized numbers (2 implied by dbra)
- movew #27,d1 | bit number for "implied" pos (+4 for rounding)
- ! moveql #-1,d3 | zero quotient (for speed a one''s complement)
- subl d5,d4 | initial subtraction, u = u - v
- 2:
- btst d1,d3 | divide until 1 in implied position
- ***************
- *** 188,194 ****
- addxl d3,d3 | shift quotient and clear bit zero
- addl d5,d4 | add (restore), u = u + v
- dbra d0,2b | give up if result is denormalized
- ! 5: subw #2,d0 | remove rounding offset for denormalized nums
- notl d3 | invert quotient to get it right
-
- clrl d1 | zero rounding bits
- --- 192,198 ----
- addxl d3,d3 | shift quotient and clear bit zero
- addl d5,d4 | add (restore), u = u + v
- dbra d0,2b | give up if result is denormalized
- ! 5: subqw #2,d0 | remove rounding offset for denormalized nums
- notl d3 | invert quotient to get it right
-
- clrl d1 | zero rounding bits
- ***************
- *** 198,205 ****
- 1: movel d3,d4 | save quotient mantissa
- jmp norm_sf | (registers on stack removed by norm_sf)
-
- # ifndef ERROR_CHECK
- ! retz: clrl d0 | zero destination
- moveml sp@+,d2-d5
- rts | no normalization needed
-
- --- 202,211 ----
- 1: movel d3,d4 | save quotient mantissa
- jmp norm_sf | (registers on stack removed by norm_sf)
-
- + #if 0
- + | this is dead code right now - retzero and retinf used (mj)
- # ifndef ERROR_CHECK
- ! retz: moveq #0,d0 | zero destination
- moveml sp@+,d2-d5
- rts | no normalization needed
-
- ***************
- *** 213,222 ****
- bclr #31,d0 |
- rts
- # endif ERROR_CHECK
- #else
-
- | single precision floating point stuff for Atari-gcc using the SFP004
- ! | or compatible boards with a memory mapped 68881
- | developed with gas
- |
- | single floating point divide routine
- --- 219,230 ----
- bclr #31,d0 |
- rts
- # endif ERROR_CHECK
- + #endif
- +
- #else
-
- | single precision floating point stuff for Atari-gcc using the SFP004
- ! | or compatible boards with a memory mapped 68881
- | developed with gas
- |
- | single floating point divide routine
- ***************
- *** 247,256 ****
- lea 0xfffffa50:w,a0
- movew #0x4400,a0@(comm) | load first argument to fp0
- cmpiw #0x8900,a0@(resp) | check
- ! movel a7@(4),a0@
- movew #0x4424,a0@(comm)
- .long 0x0c688900, 0xfff067f8
- ! movel a7@(8),a0@
- movew #0x6400,a0@(comm) | result to d0
- .long 0x0c688900, 0xfff067f8
- movel a0@,d0 | REMARK: 0/0 returns a NAN
- --- 255,264 ----
- lea 0xfffffa50:w,a0
- movew #0x4400,a0@(comm) | load first argument to fp0
- cmpiw #0x8900,a0@(resp) | check
- ! movel sp@(4),a0@
- movew #0x4424,a0@(comm)
- .long 0x0c688900, 0xfff067f8
- ! movel sp@(8),a0@
- movew #0x6400,a0@(comm) | result to d0
- .long 0x0c688900, 0xfff067f8
- movel a0@,d0 | REMARK: 0/0 returns a NAN
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_extends.cpp,v
- retrieving revision 1.4
- diff -c -r1.4 _extends.cpp
- *** 1.4 1993/03/01 17:34:03
- --- _extends.cpp 1993/05/29 20:28:27
- ***************
- *** 14,19 ****
- --- 14,22 ----
- | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
- | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
- |
- + | Revision 1.3, michal 05-93 :
- + | code cleanup
- + |
- | Revision 1.2, kub 01-90 :
- | added support for denormalized numbers
- |
- ***************
- *** 26,64 ****
- BIAS4 = 0x7F-1
- BIAS8 = 0x3FF-1
-
- ! lea sp@(4),a0 | parameter pointer
- moveml d2-d7,sp@- | save regs to keep norm_df happy
- ! movel a0@,d4 | get number
- ! clrl d5 | prepare double mantissa
-
- ! movew a0@,d0 | extract exponent
- movew d0,d2 | extract sign
- lsrw #7,d0
- - andw #0xff,d0 | kill sign bit (exponent is 8 bits)
- andl #0x7fffff,d4 | remove exponent from mantissa
-
- ! cmpb #0xff,d0
- bne nospec
- tstl d4
- beq retinf
- | ret nan
- ! movel #0x7fffffff,d0
- ! moveql #-1,d1
- return: moveml sp@+,d2-d7
- rts
- - retinf: clrl d1
- - movel #0x7ff00000,d0
- - tstw d2
- - bpl return
- - bset #31,d0
- - bra return
-
- !
- ! nospec: tstw d0 | check for zero exponent - no leading "1"
- ! beq 0f | for denormalized numbers
- ! bset #23,d4 | restore implied leading "1"
- ! bra 1f
- ! 0: addw #1,d0 | "normalize" exponent
- 1:
- addw #BIAS8-BIAS4-3,d0 | adjust bias, account for shift
- clrw d1 | dummy rounding info
- --- 29,66 ----
- BIAS4 = 0x7F-1
- BIAS8 = 0x3FF-1
-
- ! movel sp@(4),d0 | get number
- moveml d2-d7,sp@- | save regs to keep norm_df happy
- ! moveq #0,d5 | prepare double mantissa
-
- ! movel d0,d4
- ! swap d0 | extract exponent
- movew d0,d2 | extract sign
- + bclr #15,d0 | kill sign bit (exponent is 8 bits)
- lsrw #7,d0
- andl #0x7fffff,d4 | remove exponent from mantissa
-
- ! moveql #-1,d1
- ! cmpb d1,d0
- bne nospec
- tstl d4
- beq retinf
- | ret nan
- ! movel d1,d0
- ! lsrl #1,d0 | #0x7fffffff -> d0
- ! bra return
- ! retinf: movel d4,d1 | 0 -> d1
- ! movel #0xffe00000,d0
- ! lslw #1,d2 | get extension bit
- ! roxrl #1,d0 | shift in sign bit
- return: moveml sp@+,d2-d7
- rts
-
- ! nospec: bset #23,d4 | restore implied leading "1"
- ! tstw d0 | check for zero exponent - no leading "1"
- ! bne 1f | for denormalized numbers
- ! bclr #23,d4 | so clear it and ...
- ! addw #1,d0 | "normalize" exponent
- 1:
- addw #BIAS8-BIAS4-3,d0 | adjust bias, account for shift
- clrw d1 | dummy rounding info
- ***************
- *** 97,103 ****
- lea 0xfffffa50:w,a0
- movew #0x4400,a0@(comm) | load argument to fp0
- cmpiw #0x8900,a0@(resp) | check
- ! movel a7@(4),a0@ | now push arg
- movew #0x7400,a0@(comm) | result to d0/d1
- .long 0x0c688900, 0xfff067f8
- movel a0@,d0 | pop double float
- --- 99,105 ----
- lea 0xfffffa50:w,a0
- movew #0x4400,a0@(comm) | load argument to fp0
- cmpiw #0x8900,a0@(resp) | check
- ! movel sp@(4),a0@ | now push arg
- movew #0x7400,a0@(comm) | result to d0/d1
- .long 0x0c688900, 0xfff067f8
- movel a0@,d0 | pop double float
- ***************
- *** 122,130 ****
- | no NAN checking implemented since the 68881 treats this situation "correct",
- | i.e. according to IEEE
-
- ! fmoves a7@(4),fp0 | load argument to fp0
- ! fmoved fp0,a7@- | read back as double
- ! moveml a7@+,d0-d1
- rts
-
- #endif __M68881__
- --- 124,132 ----
- | no NAN checking implemented since the 68881 treats this situation "correct",
- | i.e. according to IEEE
-
- ! fmoves sp@(4),fp0 | load argument to fp0
- ! fmoved fp0,sp@- | read back as double
- ! moveml sp@+,d0-d1
- rts
-
- #endif __M68881__
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_fixdfsi.cpp,v
- retrieving revision 1.4
- diff -c -r1.4 _fixdfsi.cpp
- *** 1.4 1993/03/01 17:34:05
- --- _fixdfsi.cpp 1993/05/29 20:28:28
- ***************
- *** 40,51 ****
- lea 0xfffffa50:w,a0
- movew #0x5403,a0@(comm) | fintrz to fp0
- cmpiw #0x8900,a0@(resp) | check
- ! movel a7@(4),a0@
- ! movel a7@(8),a0@
- movew #0x6000,a0@(comm) | result to d0
- .long 0x0c688900, 0xfff067f8
- movel a0@,d0
- !
- #endif sfp004
- #ifdef __M68881__
-
- --- 40,51 ----
- lea 0xfffffa50:w,a0
- movew #0x5403,a0@(comm) | fintrz to fp0
- cmpiw #0x8900,a0@(resp) | check
- ! movel sp@(4),a0@
- ! movel sp@(8),a0@
- movew #0x6000,a0@(comm) | result to d0
- .long 0x0c688900, 0xfff067f8
- movel a0@,d0
- !
- #endif sfp004
- #ifdef __M68881__
-
- ***************
- *** 98,111 ****
- moveml a0@,d0-d1 | get the number
- movew a0@,d2 | extract exp
- movew d2,d3 | extract sign
- lsrw #4,d2
- - andw #0x07ff,d2 | kill sign bit
-
- andl #0x0fffff,d0 | remove exponent from mantissa
- bset #20,d0 | restore implied leading "1"
-
- cmpw #BIAS8,d2 | check exponent
- ! blt zero | strictly factional, no integer part ?
- cmpw #BIAS8+32,d2 | is it too big to fit in a 32-bit integer ?
- bgt toobig
-
- --- 98,111 ----
- moveml a0@,d0-d1 | get the number
- movew a0@,d2 | extract exp
- movew d2,d3 | extract sign
- + bclr #15,d2 | kill sign bit
- lsrw #4,d2
-
- andl #0x0fffff,d0 | remove exponent from mantissa
- bset #20,d0 | restore implied leading "1"
-
- cmpw #BIAS8,d2 | check exponent
- ! blt zero | strictly fractional, no integer part ?
- cmpw #BIAS8+32,d2 | is it too big to fit in a 32-bit integer ?
- bgt toobig
-
- ***************
- *** 120,126 ****
-
- 2: addl d1,d1 | shift up to align radix point
- addxl d0,d0
- ! subw #1,d2
- bgt 2b
-
- 3: cmpl #0x80000000,d0 | -2147483648 is a nasty evil special case
- --- 120,126 ----
-
- 2: addl d1,d1 | shift up to align radix point
- addxl d0,d0
- ! subqw #1,d2
- bgt 2b
-
- 3: cmpl #0x80000000,d0 | -2147483648 is a nasty evil special case
- ***************
- *** 143,149 ****
- bra 8b
-
- toobig:
- ! movel #0x7fffffff,d0 | ugh. Should cause a trap here.
- moveml sp@+,d2/d3
-
- #endif /* !defined (sfp004) && !defined (__M68881__) */
- --- 143,150 ----
- bra 8b
-
- toobig:
- ! moveq #-1,d0 | ugh. Should cause a trap here.
- ! bclr #31,d0
- moveml sp@+,d2/d3
-
- #endif /* !defined (sfp004) && !defined (__M68881__) */
- ***************
- *** 157,171 ****
- ble error_msg
- rts
- error_msg:
- ! moveml d0-d1,a7@-
- ! moveq #ERANGE,d0
- Emove d0,Errno
- pea pc@(_Overflow) | for printf
- ! pea pc@(_Error_String) |
- pea Stderr
- ! jbsr _fprintf |
- ! addl #12,a7 |
- ! moveml a7@+,d0-d1
- #endif /* ERROR_CHECK */
-
- rts
- --- 158,172 ----
- ble error_msg
- rts
- error_msg:
- ! moveml d0-d1,sp@-
- ! moveq #Erange,d0
- Emove d0,Errno
- pea pc@(_Overflow) | for printf
- ! pea pc@(_Error_String)
- pea Stderr
- ! jbsr _fprintf
- ! addl #12,sp
- ! moveml sp@+,d0-d1
- #endif /* ERROR_CHECK */
-
- rts
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_fixsfsi.cpp,v
- retrieving revision 1.3
- diff -c -r1.3 _fixsfsi.cpp
- *** 1.3 1993/03/01 17:34:07
- --- _fixsfsi.cpp 1993/05/29 20:28:30
- ***************
- *** 28,34 ****
- 1: cmpiw #0x8900,a0@(resp)
- beq 1b
- movel a0@,d0
- !
- #else /* !sfp004 */
-
- BIAS4 = 0x7F-1
- --- 28,34 ----
- 1: cmpiw #0x8900,a0@(resp)
- beq 1b
- movel a0@,d0
- !
- #else /* !sfp004 */
-
- BIAS4 = 0x7F-1
- ***************
- *** 38,45 ****
- movel d0,d1
- swap d1 | extract exp
- movew d1,d2 | extract sign
- lsrw #7,d1
- - andw #0xff,d1 | kill sign bit
-
- andl #0x7fffff,d0 | remove exponent from mantissa
- bset #23,d0 | restore implied leading "1"
- --- 38,45 ----
- movel d0,d1
- swap d1 | extract exp
- movew d1,d2 | extract sign
- + bclr #15,d1 | kill sign bit
- lsrw #7,d1
-
- andl #0x7fffff,d0 | remove exponent from mantissa
- bset #23,d0 | restore implied leading "1"
- ***************
- *** 80,86 ****
- bra 8b
-
- toobig:
- ! movel #0x7fffffff,d0 | ugh. Should cause a trap here.
- bra 8b
-
- #endif /* !sfp004*/
- --- 80,87 ----
- bra 8b
-
- toobig:
- ! moveq #-1,d0 | ugh. Should cause a trap here.
- ! bclr #31,d0 | make it #0x7fffffff
- bra 8b
-
- #endif /* !sfp004*/
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_fltsi.cpp,v
- retrieving revision 1.3
- diff -c -r1.3 _fltsi.cpp
- *** 1.3 1992/10/09 20:35:29
- --- _fltsi.cpp 1993/05/29 20:28:31
- ***************
- *** 72,86 ****
- moveml d2-d7,sp@- | save registers to make norm_df happy
-
- movel d0,d4 | prepare result mantissa
- ! clrl d5
- movew #BIAS8+32-11,d0 | radix point after 32 bits
- 0:
- movel d4,d2 | set sign flag
- - swap d2
- - tstw d2 | check sign of number
- bge 1f | nonnegative
- negl d4 | take absolute value
- 1:
- clrw d1 | set rounding = 0
- jmp norm_df
-
- --- 72,85 ----
- moveml d2-d7,sp@- | save registers to make norm_df happy
-
- movel d0,d4 | prepare result mantissa
- ! moveq #0,d5
- movew #BIAS8+32-11,d0 | radix point after 32 bits
- 0:
- movel d4,d2 | set sign flag
- bge 1f | nonnegative
- negl d4 | take absolute value
- 1:
- + swap d2 | follow norm_df conventions
- clrw d1 | set rounding = 0
- jmp norm_df
-
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_fltsisf.cpp,v
- retrieving revision 1.2
- diff -c -r1.2 _fltsisf.cpp
- *** 1.2 1992/10/09 20:35:29
- --- _fltsisf.cpp 1993/05/29 20:28:32
- ***************
- *** 39,49 ****
- movel sp@(20),d4 | prepare result mantissa
- movew #BIAS4+32-8,d0 | radix point after 32 bits
- movel d4,d2 | set sign flag
- - swap d2
- - tstw d2 | check sign of number
- bge 1f | nonnegative
- negl d4 | take absolute value
- 1:
- clrw d1 | set rounding = 0
- jmp norm_sf
-
- --- 39,48 ----
- movel sp@(20),d4 | prepare result mantissa
- movew #BIAS4+32-8,d0 | radix point after 32 bits
- movel d4,d2 | set sign flag
- bge 1f | nonnegative
- negl d4 | take absolute value
- 1:
- + swap d2 | follow norm_sf conventions
- clrw d1 | set rounding = 0
- jmp norm_sf
-
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_fxunsd.cpp,v
- retrieving revision 1.3
- diff -c -r1.3 _fxunsd.cpp
- *** 1.3 1993/03/01 17:34:09
- --- _fxunsd.cpp 1993/05/29 20:28:33
- ***************
- *** 21,29 ****
- ___fixunsdfsi:
-
- #ifdef ERROR_CHECK
- ! tstl a7@(4) | negative?
- beq Continue
- ! moveq #ERANGE,d0
- Emove d0,Errno
- pea pc@(_Negative)
- bra error_exit
- --- 21,29 ----
- ___fixunsdfsi:
-
- #ifdef ERROR_CHECK
- ! tstl sp@(4) | negative?
- beq Continue
- ! moveq #Erange,d0
- Emove d0,Errno
- pea pc@(_Negative)
- bra error_exit
- ***************
- *** 31,37 ****
- #endif /* ERROR_CHECK */
- #ifdef __M68881__
-
- ! fintrzd a7@(4),fp0 | convert
- fmovel fp0,d0
-
- #endif __M68881__
- --- 31,37 ----
- #endif /* ERROR_CHECK */
- #ifdef __M68881__
-
- ! fintrzd sp@(4),fp0 | convert
- fmovel fp0,d0
-
- #endif __M68881__
- ***************
- *** 48,55 ****
- lea 0xfffffa50:w,a0
- movew #0x5403,a0@(comm) | fintrz to fp0
- cmpiw #0x8900,a0@(resp) | check
- ! movel a7@(4),a0@
- ! movel a7@(8),a0@
- movew #0x6000,a0@(comm) | result to d0
- .long 0x0c688900, 0xfff067f8
- movel a0@,d0
- --- 48,55 ----
- lea 0xfffffa50:w,a0
- movew #0x5403,a0@(comm) | fintrz to fp0
- cmpiw #0x8900,a0@(resp) | check
- ! movel sp@(4),a0@
- ! movel sp@(8),a0@
- movew #0x6000,a0@(comm) | result to d0
- .long 0x0c688900, 0xfff067f8
- movel a0@,d0
- ***************
- *** 81,94 ****
- moveml d4/d5,sp@- | save registers
- moveml a0@,d4-d5 | get the number
- movew a0@,d0 | extract exp
- lsrw #4,d0
- - andw #0x07ff,d0 | kill sign bit
-
- andl #0x0fffff,d4 | remove exponent from mantissa
- bset #20,d4 | restore implied leading "1"
-
- cmpw #BIAS8,d0 | check exponent
- ! blt zero | strictly factional, no integer part ?
- cmpw #BIAS8+32,d0 | is it too big to fit in a 32-bit integer ?
- bgt toobig
-
- --- 81,94 ----
- moveml d4/d5,sp@- | save registers
- moveml a0@,d4-d5 | get the number
- movew a0@,d0 | extract exp
- + bclr #15,d0 | kill sign bit
- lsrw #4,d0
-
- andl #0x0fffff,d4 | remove exponent from mantissa
- bset #20,d4 | restore implied leading "1"
-
- cmpw #BIAS8,d0 | check exponent
- ! blt zero | strictly fractional, no integer part ?
- cmpw #BIAS8+32,d0 | is it too big to fit in a 32-bit integer ?
- bgt toobig
-
- ***************
- *** 107,119 ****
- beq 3f
-
- 1: lsrl #1,d4 | shift down to align radix point;
- ! addw #1,d0 | extra bits fall off the end (no rounding)
- blt 1b | shifted all the way down yet ?
- bra 3f
-
- 2: addl d5,d5 | shift up to align radix point
- addxl d4,d4
- ! subw #1,d0
- bgt 2b
- 3:
- movel d4,d0 | put integer into result register
- --- 107,119 ----
- beq 3f
-
- 1: lsrl #1,d4 | shift down to align radix point;
- ! addqw #1,d0 | extra bits fall off the end (no rounding)
- blt 1b | shifted all the way down yet ?
- bra 3f
-
- 2: addl d5,d5 | shift up to align radix point
- addxl d4,d4
- ! subqw #1,d0
- bgt 2b
- 3:
- movel d4,d0 | put integer into result register
- ***************
- *** 127,133 ****
-
- toobig:
- moveml sp@+,d4/d5
- ! movel #0x7fffffff,d0 | ugh. Should cause a trap here.
- #endif
-
- #ifdef ERROR_CHECK
- --- 127,134 ----
-
- toobig:
- moveml sp@+,d4/d5
- ! moveq #-1,d0 | ugh. Should cause a trap here.
- ! bclr #31,d0
- #endif
-
- #ifdef ERROR_CHECK
- ***************
- *** 135,150 ****
- bge error_plus |
- rts
- error_plus:
- ! moveml d0-d1,a7@-
- ! moveq #ERANGE,d0
- Emove d0,Errno
- pea pc@(_Overflow) | for printf
- error_exit:
- pea pc@(_Error_String) |
- pea Stderr
- jbsr _fprintf |
- ! addl #12,a7 |
- ! moveml a7@+,d0-d1
- #endif ERROR_CHECK
- rts
-
- --- 136,151 ----
- bge error_plus |
- rts
- error_plus:
- ! moveml d0-d1,sp@-
- ! moveq #Erange,d0
- Emove d0,Errno
- pea pc@(_Overflow) | for printf
- error_exit:
- pea pc@(_Error_String) |
- pea Stderr
- jbsr _fprintf |
- ! addl #12,sp |
- ! moveml sp@+,d0-d1
- #endif ERROR_CHECK
- rts
-
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_muldf3.cpp,v
- retrieving revision 1.4
- diff -c -r1.4 _muldf3.cpp
- *** 1.4 1993/03/01 17:34:12
- --- _muldf3.cpp 1993/05/29 20:28:35
- ***************
- *** 58,65 ****
- --- 58,72 ----
- |
- | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
- | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
- + |
- + | Revision 1.2.3 michal 05-93 (ntomczak@vm.ucs.ualberta.ca)
- + | + code smoothing
- + |
- | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
- |
- + | Revision 1.2.2 olaf 05-93:
- + | + fixed a bug for signed bug for 0.
- + |
- | Revision 1.2.1 olaf 12-92:
- | + added support for NaN and Infinites
- | + added support for -0
- ***************
- *** 79,104 ****
- moveml d2-d7,sp@-
- moveml a0@,d4-d5/d6-d7 | d4-d5 = v, d6-d7 = u
-
- movel d6,d0 | d0 = u.exp
- swap d0
- movew d0,d2 | d2 = u.sign
- lsrw #4,d0
- - andw #0x07ff,d0 | kill sign bit
-
- movel d4,d1 | d1 = v.exp
- swap d1
- ! eorw d1,d2 | d2 = u.sign ^ v.sign (in bit 31)
- lsrw #4,d1
- - andw #0x07ff,d1 | kill sign bit
- -
- - andl #0x0fffff,d6 | remove exponent from u.mantissa
- - andl #0x0fffff,d4 | remove exponent from v.mantissa
- |
- | Testing for NaN and Infinities
- |
- ! cmpw #0x7ff,d0
- beq 0f
- ! cmpw #0x7ff,d1
- bne nospec
- bra 1f
- | first operand is special
- --- 86,112 ----
- moveml d2-d7,sp@-
- moveml a0@,d4-d5/d6-d7 | d4-d5 = v, d6-d7 = u
-
- + movel #0x0fffff,d3
- movel d6,d0 | d0 = u.exp
- + andl d3,d6 | remove exponent from u.mantissa
- swap d0
- movew d0,d2 | d2 = u.sign
- + bclr #15,d0 | kill sign bit
- lsrw #4,d0
-
- movel d4,d1 | d1 = v.exp
- + andl d3,d4 | remove exponent from v.mantissa
- swap d1
- ! eorw d1,d2 | d2 = u.sign ^ v.sign (in bit 15)
- ! bclr #15,d1 | kill sign bit
- lsrw #4,d1
- |
- | Testing for NaN and Infinities
- |
- ! movew #0x7ff,d3
- ! cmpw d3,d0
- beq 0f
- ! cmpw d3,d1
- bne nospec
- bra 1f
- | first operand is special
- ***************
- *** 110,129 ****
- bne retinf | Inf * x == Inf
- orl d5,d4
- beq retnan | Inf * 0 == NaN
- ! retinf:
- ! clrl d1
- ! tstl d2
- ! bpl 0f
- ! movel #0xfff00000,d0
- return: moveml sp@+,d2-d7
- rts
- !
- !
- ! 0: movel #0x7ff00000,d0
- ! bra return
- !
- ! retnan: movel #0x7fffffff,d0
- ! moveql #-1,d1
- bra return
- |
- | v is special
- --- 118,138 ----
- bne retinf | Inf * x == Inf
- orl d5,d4
- beq retnan | Inf * 0 == NaN
- ! |
- ! | Return Infinity with correct sign
- ! |
- ! retinf: moveq #0,d1
- ! movel #0xffe00000,d0 | we will return #0xfff00000 or #0x7ff00000
- ! lslw #1,d2
- ! roxrl #1,d0 | shift in high bit as given by d2
- return: moveml sp@+,d2-d7
- rts
- ! |
- ! | Return NaN
- ! |
- ! retnan: moveql #-1,d1
- ! movel d1,d0
- ! bclr #31,d0 | 0x7fffffff -> d0
- bra return
- |
- | v is special
- ***************
- *** 137,159 ****
- bra retinf
- |
- | end of NaN and Inf.
- ! |
- nospec: subw #16,sp | multiplication accumulator
-
- - tstw d0 | check for zero exponent - no leading "1"
- - beq 0f
- bset #20,d6 | restore implied leading "1"
- ! bra 1f
- ! 0: addw #1,d0 | "normalize" exponent
- 1: movel d6,d3
- orl d7,d3
- beq retz | multiplying by zero
-
- - tstw d1 | check for zero exponent - no leading "1"
- - beq 0f
- bset #20,d4 | restore implied leading "1"
- ! bra 1f
- ! 0: addw #1,d1 | "normalize" exponent
- 1: movel d4,d3
- orl d5,d3
- beq retz | multiplying by zero
- --- 146,168 ----
- bra retinf
- |
- | end of NaN and Inf.
- ! |
- nospec: subw #16,sp | multiplication accumulator
-
- bset #20,d6 | restore implied leading "1"
- ! tstw d0 | check for zero exponent - no leading "1"
- ! bne 1f
- ! bclr #20,d6 | remove it
- ! addw #1,d0 | "normalize" exponent
- 1: movel d6,d3
- orl d7,d3
- beq retz | multiplying by zero
-
- bset #20,d4 | restore implied leading "1"
- ! tstw d1 | check for zero exponent - no leading "1"
- ! bne 1f
- ! bclr #20,d4 | remove it
- ! addw #1,d1 | "normalize" exponent
- 1: movel d4,d3
- orl d5,d3
- beq retz | multiplying by zero
- ***************
- *** 161,171 ****
- addw d1,d0 | add exponents,
- subw #BIAS8+16-11,d0 | remove excess bias, acnt for repositioning
-
- ! clrl sp@ | initialize 128-bit product to zero
- ! clrl sp@(4)
- ! clrl sp@(8)
- ! clrl sp@(12)
- ! lea sp@(8),a1 | accumulator pointer
-
- | see Knuth, Seminumerical Algorithms, section 4.3. algorithm M
-
- --- 170,182 ----
- addw d1,d0 | add exponents,
- subw #BIAS8+16-11,d0 | remove excess bias, acnt for repositioning
-
- ! lea sp@,a1 | initialize 128-bit product to zero
- ! moveq #0,d3
- ! movel d3,a1@+
- ! movel d3,a1@+
- ! movel d3,a1@+
- ! movel d3,a1@
- ! subqw #4,a1 | an address of sp@(8) in a1
-
- | see Knuth, Seminumerical Algorithms, section 4.3. algorithm M
-
- ***************
- *** 202,209 ****
-
- moveml sp@(2),d4-d7 | get the 112 valid bits
- clrw d7 | (pad to 128)
- 2:
- ! cmpl #0x0000ffff,d4 | multiply (shift) until
- bhi 3f | 1 in upper 16 result bits
- cmpw #9,d0 | give up for denormalized numbers
- ble 3f
- --- 213,221 ----
-
- moveml sp@(2),d4-d7 | get the 112 valid bits
- clrw d7 | (pad to 128)
- + movel #0x0000ffff,d3
- 2:
- ! cmpl d3,d4 | multiply (shift) until
- bhi 3f | 1 in upper 16 result bits
- cmpw #9,d0 | give up for denormalized numbers
- ble 3f
- ***************
- *** 227,235 ****
- orb #1,d1 | set "sticky bit" if any low-order set
- 4: addw #16,sp | remove accumulator from stack
- jmp norm_df | (result in d4/d5)
- !
- ! retz: clrl d0 | save zero as result
- ! clrl d1
- addw #16,sp
- moveml sp@+,d2-d7
- rts | no normalizing neccessary
- --- 239,249 ----
- orb #1,d1 | set "sticky bit" if any low-order set
- 4: addw #16,sp | remove accumulator from stack
- jmp norm_df | (result in d4/d5)
- ! | | norm_df does not return here
- ! retz: moveq #0,d0 | save zero as result
- ! movel d0,d1
- ! lslw #1,d2 | fill X bit
- ! roxrl #1,d0 | set high bit of d0 accordingly
- addw #16,sp
- moveml sp@+,d2-d7
- rts | no normalizing neccessary
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_mulsf3.cpp,v
- retrieving revision 1.4
- diff -c -r1.4 _mulsf3.cpp
- *** 1.4 1993/03/01 17:34:14
- --- _mulsf3.cpp 1993/05/29 20:28:36
- ***************
- *** 30,39 ****
- lea 0xfffffa50:w,a0
- movew #0x4400,a0@(comm) | load first argument to fp0
- cmpiw #0x8900,a0@(resp) | check
- ! movel a7@(4),a0@
- movew #0x4427,a0@(comm)
- .long 0x0c688900, 0xfff067f8
- ! movel a7@(8),a0@
- movew #0x6400,a0@(comm) | result to d0
- .long 0x0c688900, 0xfff067f8
- movel a0@,d0
- --- 30,39 ----
- lea 0xfffffa50:w,a0
- movew #0x4400,a0@(comm) | load first argument to fp0
- cmpiw #0x8900,a0@(resp) | check
- ! movel sp@(4),a0@
- movew #0x4427,a0@(comm)
- .long 0x0c688900, 0xfff067f8
- ! movel sp@(8),a0@
- movew #0x6400,a0@(comm) | result to d0
- .long 0x0c688900, 0xfff067f8
- movel a0@,d0
- ***************
- *** 45,52 ****
- --- 45,59 ----
- |
- | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
- | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
- + |
- + | Revision 1.2.3 michal 05-93 (ntomczak@vm.ucs.ualberta.ca)
- + | + code smoothing
- + |
- | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
- |
- + | Revision 1.2.2 olaf 05-93
- + | + fixed a bug with -0.
- + |
- | Revision 1.2.1 olaf 12-92:
- | + added support for NaN and Infinites
- | + added support for -0
- ***************
- *** 67,93 ****
- moveml d2-d5,sp@-
- moveml a0@,d4/d5 | d4 = v, d5 = u
-
- !
- movel d5,d0 | d0 = u.exp
- swap d0
- movew d0,d2 | d2 = u.sign
- lsrw #7,d0
- - andw #0xff,d0 | kill sign bit
-
- movel d4,d1 | d1 = v.exp
- swap d1
- ! eorw d1,d2 | d2 = u.sign ^ v.sign (in bit 31)
- lsrw #7,d1
- - andw #0xff,d1 | kill sign bit
-
- - andl #0x7fffff,d5 | remove exponent from u.mantissa
- - andl #0x7fffff,d4 | remove exponent from v.mantissa
- |
- | Testing for NaN and Infinities
- |
- ! cmpb #0xff,d0
- beq 0f
- ! cmpb #0xff,d1
- bne nospec
- bra 1f
- | first operand is special
- --- 74,101 ----
- moveml d2-d5,sp@-
- moveml a0@,d4/d5 | d4 = v, d5 = u
-
- ! movel #0x7fffff,d3
- movel d5,d0 | d0 = u.exp
- + andl d3,d5 | remove exponent from u.mantissa
- swap d0
- movew d0,d2 | d2 = u.sign
- + bclr #15,d0 | kill sign bit
- lsrw #7,d0
-
- movel d4,d1 | d1 = v.exp
- + andl d3,d4 | remove exponent from v.mantissa
- swap d1
- ! eorw d1,d2 | d2 = u.sign ^ v.sign (in bit 15)
- ! bclr #15,d1 | kill sign bit
- lsrw #7,d1
-
- |
- | Testing for NaN and Infinities
- |
- ! moveq #-1,d3
- ! cmpb d3,d0
- beq 0f
- ! cmpb d3,d1
- bne nospec
- bra 1f
- | first operand is special
- ***************
- *** 100,116 ****
- tstl d4
- beq retnan | Inf * 0 == NaN
-
- ! retinf: tstl d2
- ! bpl 0f
- ! movel #0xff800000,d0
- return: moveml sp@+,d2-d5
- rts
- !
- !
- ! 0: movel #0x7f800000,d0
- ! bra return
- !
- ! retnan: movel #0x7fffffff,d0
- bra return
- |
- | v is special
- --- 108,126 ----
- tstl d4
- beq retnan | Inf * 0 == NaN
-
- ! |
- ! | Return Infinity with correct sign
- ! |
- ! retinf: movel #0xff000000,d0 | we will return #0xff800000 or #0x7f800000
- ! lslw #1,d2
- ! roxrl #1,d0 | shift in high bit as given by d2
- return: moveml sp@+,d2-d5
- rts
- ! |
- ! | Return NaN
- ! |
- ! retnan: moveql #-1,d0
- ! lsrl #1,d0 | 0x7fffffff -> d0
- bra return
- |
- | v is special
- ***************
- *** 124,144 ****
- bra retinf
- |
- | end of NaN and Inf.
- ! |
- ! nospec: subw #8,sp | multiplication accumulator
- tstw d0 | check for zero exponent - no leading "1"
- ! beq 0f
- ! bset #23,d5 | restore implied leading "1"
- ! bra 1f
- ! 0: addw #1,d0 | "normalize" exponent
- 1: tstl d5
- beq retz | multiplying zero
-
- - tstw d1 | check for zero exponent - no leading "1"
- - beq 0f
- bset #23,d4 | restore implied leading "1"
- ! bra 1f
- ! 0: addw #1,d1 | "normalize" exponent
- 1: tstl d4
- beq retz | multiply by zero
-
- --- 134,154 ----
- bra retinf
- |
- | end of NaN and Inf.
- ! |
- ! nospec: bset #23,d5 | restore implied leading "1"
- ! subw #8,sp | multiplication accumulator
- tstw d0 | check for zero exponent - no leading "1"
- ! bne 1f
- ! bclr #23,d5 | remove it
- ! addqw #1,d0 | "normalize" exponent
- 1: tstl d5
- beq retz | multiplying zero
-
- bset #23,d4 | restore implied leading "1"
- ! tstw d1 | check for zero exponent - no leading "1"
- ! bne 1f
- ! bclr #23,d4 | remove it
- ! addqw #1,d1 | "normalize" exponent
- 1: tstl d4
- beq retz | multiply by zero
-
- ***************
- *** 172,179 ****
- | [TOP 16 BITS SHOULD BE ZERO !]
- moveml sp@(2),d4-d5 | get the 48 valid mantissa bits
- clrw d5 | (pad to 64)
- 2:
- ! cmpl #0x0000ffff,d4 | multiply (shift) until
- bhi 3f | 1 in upper 16 result bits
- cmpw #9,d0 | give up for denormalized numbers
- ble 3f
- --- 182,191 ----
- | [TOP 16 BITS SHOULD BE ZERO !]
- moveml sp@(2),d4-d5 | get the 48 valid mantissa bits
- clrw d5 | (pad to 64)
- +
- + movel #0x0000ffff,d3
- 2:
- ! cmpl d3,d4 | multiply (shift) until
- bhi 3f | 1 in upper 16 result bits
- cmpw #9,d0 | give up for denormalized numbers
- ble 3f
- ***************
- *** 193,199 ****
- 4: addw #8,sp | remove accumulator from stack
- jmp norm_sf | (result in d4)
-
- ! retz: clrl d0 | save zero as result
- addw #8,sp
- moveml sp@+,d2-d5
- rts | no normalizing neccessary
- --- 205,213 ----
- 4: addw #8,sp | remove accumulator from stack
- jmp norm_sf | (result in d4)
-
- ! retz: moveq #0,d0 | save zero as result
- ! lslw #1,d2 | and set it sign as for d2
- ! roxrl #1,d0
- addw #8,sp
- moveml sp@+,d2-d5
- rts | no normalizing neccessary
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_normdf.cpp,v
- retrieving revision 1.7
- diff -c -r1.7 _normdf.cpp
- *** 1.7 1992/12/28 07:56:08
- --- _normdf.cpp 1993/05/29 20:28:37
- ***************
- *** 7,12 ****
- --- 7,18 ----
- |
- | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
- | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
- + |
- + | Revision 1.6.3 michal 05-93 (ntomczak@vm.ucs.ualberta.ca)
- + | + restored and ensured future synchronization with errno codes
- + | + removed bogus error when normalizing legitimate zero
- + | + small mods to shave off few cycles
- + |
- | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
- |
- | Revision 1.6.2 olaf 12-92:
- ***************
- *** 73,84 ****
- movel a0@+,d0 | get exponent
- movel a0@+,d2 | get sign
- bpl 0f | or bit 31 to bit 15 for later tests
- ! orw #0x8000,d2
- 0: movel a0@+,d1 | rounding information
-
- ! cmpl #0x7fff,d0 | test exponent
- bgt oflow
- ! cmpl #-0x8000,d0
- blt retz
- # endif
-
- --- 79,92 ----
- movel a0@+,d0 | get exponent
- movel a0@+,d2 | get sign
- bpl 0f | or bit 31 to bit 15 for later tests
- ! bset #15,d2
- 0: movel a0@+,d1 | rounding information
-
- ! movel #0x7fff,d3
- ! cmpl d3,d0 | test exponent
- bgt oflow
- ! notl d3 | #-0x8000 -> d3
- ! cmpl d3,d0
- blt retz
- # endif
-
- ***************
- *** 90,96 ****
- orl d5,d3
- bne 1f
- tstb d1
- ! beq retz
- 1:
- movel d4,d3
- andl #0xfffff000,d3 | fast shift, 16 bits ?
- --- 98,104 ----
- orl d5,d3
- bne 1f
- tstb d1
- ! beq retzok
- 1:
- movel d4,d3
- andl #0xfffff000,d3 | fast shift, 16 bits ?
- ***************
- *** 122,128 ****
- 4:
- andb #1,d2
- orb d2,d1 | make least sig bit sticky
- ! movel #0xfff00000,d6
- 5: movel d4,d3 | multiply (shift) until
- andl d6,d3 | one in implied position
- bne 6f
- --- 130,136 ----
- 4:
- andb #1,d2
- orb d2,d1 | make least sig bit sticky
- ! asrl #1,d6 | #0xfff00000 -> d6
- 5: movel d4,d3 | multiply (shift) until
- andl d6,d3 | one in implied position
- bne 6f
- ***************
- *** 137,143 ****
- bge 8f | round down - no action neccessary
- negb d1
- bvc 7f | round up
- ! movew d5,d1 | tie case - round to even
- | dont need rounding bits any more
- andw #1,d1 | check if even
- beq 8f | mantissa is even - no action necessary
- --- 145,151 ----
- bge 8f | round down - no action neccessary
- negb d1
- bvc 7f | round up
- ! movew d5,d1 | tie case - round to even
- | dont need rounding bits any more
- andw #1,d1 | check if even
- beq 8f | mantissa is even - no action necessary
- ***************
- *** 151,170 ****
- addw #1,d0 | correct exponent for denormalized numbers
- bra 2b
- 0: movel d4,d3 | check for rounding overflow
- ! andl #0xffe00000,d3
- bne 2b | go back and renormalize
- 8:
- movel d4,d3 | check if normalization caused an underflow
- orl d5,d3
- beq retz
- ! cmpw #0,d0 | check for exponent overflow or underflow
- blt retz
- cmpw #2047,d0
- bge oflow
-
- ! lslw #4,d0 | re-position exponent
- ! andw #0x8000,d2 | sign bit
- ! orw d2,d0
- swap d0 | map to upper word
- clrw d0
- andl #0x0fffff,d4 | top mantissa bits
- --- 159,179 ----
- addw #1,d0 | correct exponent for denormalized numbers
- bra 2b
- 0: movel d4,d3 | check for rounding overflow
- ! asll #1,d6 | #0xffe00000 -> d3
- ! andl d6,d3
- bne 2b | go back and renormalize
- 8:
- movel d4,d3 | check if normalization caused an underflow
- orl d5,d3
- beq retz
- ! tstw d0 | check for exponent overflow or underflow
- blt retz
- cmpw #2047,d0
- bge oflow
-
- ! lslw #5,d0 | re-position exponent - one bit too high
- ! lslw #1,d2 | get X bit
- ! roxrw #1,d0 | shift it into sign position
- swap d0 | map to upper word
- clrw d0
- andl #0x0fffff,d4 | top mantissa bits
- ***************
- *** 175,187 ****
- rts
-
- retz:
- ! moveq #ERANGE,d0
- Emove d0,Errno
- ! clrl d0 | return zero value
- ! clrl d1
- ! tstw d2
- ! bpl 0f | -0
- ! bset #31,d0
- 0: moveml sp@+,d2-d7
- rts
-
- --- 184,196 ----
- rts
-
- retz:
- ! moveq #Erange,d0
- Emove d0,Errno
- ! retzok:
- ! moveq #0,d0 | return zero value
- ! movel d0,d1
- ! lslw #1,d2 | set value of extension
- ! roxrl #1,d0 | and move it to hight bit of d0
- 0: moveml sp@+,d2-d7
- rts
-
- ***************
- *** 191,206 ****
- pea Stderr
- jbsr _fprintf |
- addql #8,a7 |
- ! moveq #ERANGE,d0
- Emove d0,Errno
- #endif ERROR_CHECK
-
- | moveml pc@(__infinitydf),d0-d1 | return infinity value
- moveml __infinitydf,d0-d1 | return infinty value
- ! andw #0x8000,d2 | get sign bit of argument
- ! swap d2
- ! clrw d2
- ! orl d2,d0
- moveml sp@+,d2-d7 | should really cause trap ?!? (mjr: why?)
- rts
-
- --- 200,215 ----
- pea Stderr
- jbsr _fprintf |
- addql #8,a7 |
- ! moveq #Erange,d0
- Emove d0,Errno
- #endif ERROR_CHECK
-
- | moveml pc@(__infinitydf),d0-d1 | return infinity value
- moveml __infinitydf,d0-d1 | return infinty value
- ! tstw d2
- ! bpl 1f
- ! bset #31,d0
- ! 1:
- moveml sp@+,d2-d7 | should really cause trap ?!? (mjr: why?)
- rts
-
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_normsf.cpp,v
- retrieving revision 1.5
- diff -c -r1.5 _normsf.cpp
- *** 1.5 1993/01/13 14:30:49
- --- _normsf.cpp 1993/05/29 20:28:38
- ***************
- *** 7,12 ****
- --- 7,18 ----
- |
- | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
- | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
- + |
- + | Revision 1.4.4 michal 05-93 (ntomczak@vm.ucs.ualberta.ca)
- + | + restored and ensured future synchronization with errno codes
- + | + removed bogus error when normalizing legitimate zero
- + | + small mods to shave off few cycles
- + |
- | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
- |
- | Revision 1.4.3 olaf 12-92:
- ***************
- *** 60,92 ****
-
- | internal entry for floating point package, saves time
- | d0=u.exp, d2=u.sign, d1=rounding bits, d4/d5=mantissa
- ! | registers d2-d7 must be saved on the stack !
- norm_sf:
- tstl d4 | rounding and u.mant == 0 ?
- bne 0f
- tstb d1
- ! beq retz
- 0:
- clrb d2 | "sticky byte"
- ! movel #0xff000000,d5
- ! 1: tstw d0 | divide (shift)
- ble 0f | denormalized number
- movel d4,d3
- andl d5,d3 | or until no bits above 23
- beq 2f
- ! 0: addw #1,d0 | increment exponent
- lsrl #1,d4
- orb d1,d2 | set "sticky"
- roxrb #1,d1 | shift into rounding bits
- ! bra 1b
- 2:
- andb #1,d2
- orb d2,d1 | make least sig bit "sticky"
- ! movel #0xff800000,d5
- 3: movel d4,d3 | multiply (shift) until
- andl d5,d3 | one in "implied" position
- bne 4f
- ! subw #1,d0 | decrement exponent
- beq 4f | too small. store as denormalized number
- addb d1,d1 | some doubt about this one *
- addxl d4,d4
- --- 66,98 ----
-
- | internal entry for floating point package, saves time
- | d0=u.exp, d2=u.sign, d1=rounding bits, d4/d5=mantissa
- ! | registers d2-d5 must be saved on the stack !
- norm_sf:
- tstl d4 | rounding and u.mant == 0 ?
- bne 0f
- tstb d1
- ! beq retzok
- 0:
- clrb d2 | "sticky byte"
- ! 1: movel #0xff000000,d5
- ! 7: tstw d0 | divide (shift)
- ble 0f | denormalized number
- movel d4,d3
- andl d5,d3 | or until no bits above 23
- beq 2f
- ! 0: addqw #1,d0 | increment exponent
- lsrl #1,d4
- orb d1,d2 | set "sticky"
- roxrb #1,d1 | shift into rounding bits
- ! bra 7b
- 2:
- andb #1,d2
- orb d2,d1 | make least sig bit "sticky"
- ! asrl #1,d5 | #0xff800000 -> d5
- 3: movel d4,d3 | multiply (shift) until
- andl d5,d3 | one in "implied" position
- bne 4f
- ! subqw #1,d0 | decrement exponent
- beq 4f | too small. store as denormalized number
- addb d1,d1 | some doubt about this one *
- addxl d4,d4
- ***************
- *** 98,104 ****
- bvc 5f | round up
- movew d4,d1 | tie case - round to even
- | dont need rounding bits any more
- ! andw #1,d1 | check if even
- beq 6f | mantissa is even - no action necessary
- | fall through
-
- --- 104,110 ----
- bvc 5f | round up
- movew d4,d1 | tie case - round to even
- | dont need rounding bits any more
- ! andw #1,d1 | check if even
- beq 6f | mantissa is even - no action necessary
- | fall through
-
- ***************
- *** 110,128 ****
- addw #1,d0 | correct exponent for denormalized numbers
- bra 1b
- 0: movel d4,d3 | check for rounding overflow
- ! andl #0xff000000,d3
- ! bne 1b | go back and renormalize
- 6:
- tstl d4 | check if normalization caused an underflow
- beq retz
- ! cmpw #0,d0 | check for exponent overflow or underflow
- blt retz
- cmpw #255,d0
- bge oflow
-
- ! lslw #7,d0 | re-position exponent
- ! andw #0x8000,d2 | sign bit
- ! orw d2,d0
- swap d0 | map to upper word
- clrw d0
- andl #0x7fffff,d4 | top mantissa bits
- --- 116,135 ----
- addw #1,d0 | correct exponent for denormalized numbers
- bra 1b
- 0: movel d4,d3 | check for rounding overflow
- ! asll #1,d5 | #0xff000000 -> d5
- ! andl d5,d3
- ! bne 7b | go back and renormalize
- 6:
- tstl d4 | check if normalization caused an underflow
- beq retz
- ! tstw d0 | check for exponent overflow or underflow
- blt retz
- cmpw #255,d0
- bge oflow
-
- ! lslw #8,d0 | re-position exponent - one bit too high
- ! lslw #1,d2 | get X bit
- ! roxrw #1,d0 | shift it into sign position
- swap d0 | map to upper word
- clrw d0
- andl #0x7fffff,d4 | top mantissa bits
- ***************
- *** 130,163 ****
- moveml sp@+,d2-d5
- rts
-
- ! retz: moveq #ERANGE,d0
- Emove d0,Errno
- ! clrl d0
- ! tstw d2
- ! bpl 0f | -0
- ! bset #31,d0
- ! 0: moveml sp@+,d2-d5
- rts
-
- ! oflow:
-
- #ifdef ERROR_CHECK
- ! movel d1,a7@-
- pea pc@(LC0)
- pea Stderr
- jbsr _fprintf |
- ! addql #8,a7 |
- ! movel a7@+,d1
- #endif ERROR_CHECK
-
- | movel pc@(__infinitysf),d0 | return infinity value
- movel __infinitysf,d0
-
- ! btst #15,d2 | transfer sign
- ! beq ofl_clear | (mjr++)
- bset #31,d0 |
- - moveml sp@+,d2-d5
- - rts
- ofl_clear:
- moveml sp@+,d2-d5 | should really cause trap ?!?
- rts
- --- 137,168 ----
- moveml sp@+,d2-d5
- rts
-
- ! retz: moveq #Erange,d0
- Emove d0,Errno
- ! retzok:
- ! moveq #0,d0
- ! lslw #1,d2
- ! roxrl #1,d0 | sign of 0 is the same as of d2
- ! moveml sp@+,d2-d5
- rts
-
- ! oflow:
-
- #ifdef ERROR_CHECK
- ! movel d1,sp@-
- pea pc@(LC0)
- pea Stderr
- jbsr _fprintf |
- ! addql #8,sp |
- ! movel sp@+,d1
- #endif ERROR_CHECK
-
- | movel pc@(__infinitysf),d0 | return infinity value
- movel __infinitysf,d0
-
- ! tstw d2 | transfer sign
- ! bge ofl_clear | (mjr++)
- bset #31,d0 |
- ofl_clear:
- moveml sp@+,d2-d5 | should really cause trap ?!?
- rts
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_truncdf.cpp,v
- retrieving revision 1.4
- diff -c -r1.4 _truncdf.cpp
- *** 1.4 1993/03/01 17:34:16
- --- _truncdf.cpp 1993/05/29 20:28:40
- ***************
- *** 48,53 ****
- --- 48,58 ----
- |
- | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
- | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
- + |
- + | Revision 1.2.2 michal 05-93: (ntomczak@vm.ucs.ualberta.ca)
- + | + corrected bug in setting sign of returned Inf
- + | + code cleanup
- + |
- | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
- |
- | Revision 1.2.1 olaf 12-92 :
- ***************
- *** 65,101 ****
- BIAS4 = 0x7F-1
- BIAS8 = 0x3FF-1
-
- ! lea sp@(4),a0 | parameter pointer
- moveml d2-d5,sp@- | save regs
- - moveml a0@,d4-d5 | get number
-
- ! movew a0@,d0 | extract exponent
- movew d0,d2 | extract sign
- lsrw #4,d0
- - andw #0x7ff,d0 | kill sign bit
- andl #0x0fffff,d4 | remove exponent from mantissa
- |
- |
- |
- cmpw #0x7ff,d0
- bne nospec
- ! orl d4,d5
- bne retnan
- ! movel #0x7f800000,d0
- ! tstl d4
- ! bpl return
- ! bset #31,d0
- return: moveml sp@+,d2-d5
- rts
- ! retnan: movel #0x7fffffff,d0
- bra return
-
- ! nospec:
- ! tstw d0 | check for zero exponent - no leading "1"
- ! beq 0f | for denormalized numbers
- bset #20,d4 | restore implied leading "1"
- ! bra 1f
- ! 0: addw #1,d0 | "normalize" exponent
- 1:
- addw #BIAS4-BIAS8,d0 | adjust bias
-
- --- 70,122 ----
- BIAS4 = 0x7F-1
- BIAS8 = 0x3FF-1
-
- ! moveml sp@(4),d0-d1 | get number
- moveml d2-d5,sp@- | save regs
-
- ! movel d0,d4 | save for norm_df
- ! swap d0 | extract exponent
- movew d0,d2 | extract sign
- + bclr #15,d0 | kill sign bit
- lsrw #4,d0
- andl #0x0fffff,d4 | remove exponent from mantissa
- |
- |
- |
- cmpw #0x7ff,d0
- bne nospec
- ! orl d4,d1
- bne retnan
- ! movel #0xff00000,d0
- ! lslw #1,d2
- ! roxrl #1,d0
- return: moveml sp@+,d2-d5
- rts
- ! retnan: moveq #-1,d0
- ! lsrl #1,d0 | #0x7fffffff -> d0
- bra return
-
- ! | Should we really return SNaN, which has a sign bit set accordingly??
- ! | if yes, then the following code can be used instead -- mj
- ! |
- ! | cmpw #0x7ff,d0
- ! | bne nospec
- ! | orl d4,d1
- ! | bne retnan
- ! | movel #0xff00000,d0
- ! |return:
- ! | lslw #1,d2 | set X bit
- ! | roxrl #1,d0 | roll in sign bit
- ! | moveml sp@+,d2-d5
- ! | rts
- ! |retnan: moveq #-1,d0
- ! | bra return
- !
- ! nospec: movel d1,d5
- bset #20,d4 | restore implied leading "1"
- ! tstw d0 | check for zero exponent - no leading "1"
- ! bne 1f | for denormalized numbers
- ! bclr #20,d4 | ... so do not do it but instead
- ! addw #1,d0 | "normalize" exponent
- 1:
- addw #BIAS4-BIAS8,d0 | adjust bias
-
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/errbase.h,v
- retrieving revision 1.1
- diff -c -r1.1 errbase.h
- *** 1.1 1992/10/09 20:35:29
- --- errbase.h 1993/05/29 20:28:41
- ***************
- *** 2,12 ****
- * Errno defs to be included in *.ss floating point routines, from <errno.h>
- * -- hyc@hanauma.jpl.nasa.gov, 9-17-92
- */
-
- .globl _errno
-
- ! EDOM = 62
- ! ERANGE = 63
-
- #ifdef __MBASE__
- #define Errno __MBASE__@(_errno)
- --- 2,15 ----
- * Errno defs to be included in *.ss floating point routines, from <errno.h>
- * -- hyc@hanauma.jpl.nasa.gov, 9-17-92
- */
- + #define AssemB
- + #include "errno.h"
- + #undef AssemB
-
- .globl _errno
-
- ! Edom = EDOM
- ! Erange = ERANGE
-
- #ifdef __MBASE__
- #define Errno __MBASE__@(_errno)
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/frexp.cpp,v
- retrieving revision 1.6
- diff -c -r1.6 frexp.cpp
- *** 1.6 1992/10/09 20:35:29
- --- frexp.cpp 1993/05/29 20:28:43
- ***************
- *** 11,17 ****
- | ported to 68000 by Kai-Uwe Bloem, 12/89
- | #1 original author: Peter S. Housel 9/21/88,01/17/89,03/19/89,5/24/89
- | #2 added support for denormalized numbers -kub-, 01/90
- ! | # ported to gcc ++jrb 04/90
- |-----------------------------------------------------------------------------
-
- BIAS8 = 0x3ff - 1
- --- 11,19 ----
- | ported to 68000 by Kai-Uwe Bloem, 12/89
- | #1 original author: Peter S. Housel 9/21/88,01/17/89,03/19/89,5/24/89
- | #2 added support for denormalized numbers -kub-, 01/90
- ! | #3 ported to gcc ++jrb 04/90
- ! | #4 support for signed 0 - consistently with the rest - michal, 05/93
- ! | and some code cleanup
- |-----------------------------------------------------------------------------
-
- BIAS8 = 0x3ff - 1
- ***************
- *** 25,62 ****
- #else
- clrl a0@
- #endif
- ! tstl sp@(4) | 1st arg == 0 ?
- bne nonzero
- ! tstl sp@(8)
- bne nonzero
- ! clrl d0
- ! clrl d1
- ! rts
- nonzero:
- ! lea sp@(4),a1
- ! moveml d2-d7,sp@-
- ! 2:
- ! movew a1@,d0 | extract value.exp
- ! movew d0,d2 | extract value.sign ++jrb
- lsrw #4,d0
- ! andw #0x7ff,d0 | kill sign bit
- cmpw #BIAS8,d0 | get out of loop if finally (a1) in [0.5,1.0)
- beq 3f
-
- ! andw #0x0f,a1@ | remove exponent from value.mantissa
- ! tstw d0 | check for zero exponent - no leading 1
- ! beq 0f
- ! orw #0x10,a1@ | restore implied leading 1
- ! bra 1f
- ! 0: addw #1,d0
- ! 1:
- movel a1@,d1 | check for zero
- orl a1@(4),d1
- beq 3f | if zero, all done : exp = 0, num = 0.0
- !
- subw #BIAS8,d0 | remove bias
- ! #ifdef __MSHORT__
- ! addw d0,a0@ | add current exponent in
- #else
- extl d0
- addl d0,a0@ | add current exponent in
- --- 27,69 ----
- #else
- clrl a0@
- #endif
- ! lea sp@(4),a1 | sp@(4) -> a1 - an address of value
- ! | | and a1@(8) - an address of *eptr
- ! movel a1@,d0 | keep value.sign
- ! movel d0,d1
- ! bclr #31,d1 | kill sign bit
- ! tstl d1 | 1st arg == 0 ?
- bne nonzero
- ! tstl a1@(4)
- bne nonzero
- ! rts | if 0 or -0 then d0 and d1 already set
- nonzero:
- ! movel d2,sp@-
- ! 2: | return here when looping
- ! swap d0 | sign and exponent into lower 16 bits
- ! movew d0,d2 | set d2 for norm_df
- ! bclr #15,d0 | kill sign bit
- lsrw #4,d0
- !
- cmpw #BIAS8,d0 | get out of loop if finally (a1) in [0.5,1.0)
- beq 3f
-
- ! moveq #0x0f,d1 | remove exponent from value.mantissa
- ! andb d2,d1 | four upper bits of value in d1
- ! bset #4,d1 | implied leading 1
- ! tstw d0 | check for zero exponent
- ! bne 1f
- ! addqw #1,d0
- ! bclr #4,d1 | nah, we do not need stinkin leadin 1
- ! 1: movew d1,a1@ | save results of our efforts
- !
- movel a1@,d1 | check for zero
- orl a1@(4),d1
- beq 3f | if zero, all done : exp = 0, num = 0.0
- ! | sign of zero is correct
- subw #BIAS8,d0 | remove bias
- ! #ifdef __MSHORT__
- ! addw d0,a0 | add current exponent in
- #else
- extl d0
- addl d0,a0@ | add current exponent in
- ***************
- *** 68,79 ****
- moveml d2-d7,sp@- | ... need to copy with -mshort)
- moveml a1@,d4-d5
- jmp norm_df | normalize result
- ! L0:
- moveml d0-d1,a1@
- bra 2b | loop around to catch denormalized numbers
- 3:
- moveml a1@,d0-d1
- ! moveml sp@+,d2-d7
- | d0-d1 has normalized mantissa
- rts
-
- --- 75,87 ----
- moveml d2-d7,sp@- | ... need to copy with -mshort)
- moveml a1@,d4-d5
- jmp norm_df | normalize result
- ! L0: | norm_df does not affect a0 or a1
- ! | | but it pops d2-d7
- moveml d0-d1,a1@
- bra 2b | loop around to catch denormalized numbers
- 3:
- moveml a1@,d0-d1
- ! movel sp@+,d2
- | d0-d1 has normalized mantissa
- rts
-
- ***************
- *** 94,100 ****
- |#######################################################################
- | a0: pointer to n
- | sp@(12) address of resulting exponent (n)
- !
- .text; .even
-
- .globl _frexp
- --- 102,108 ----
- |#######################################################################
- | a0: pointer to n
- | sp@(12) address of resulting exponent (n)
- !
- .text; .even
-
- .globl _frexp
- ***************
- *** 161,171 ****
- | bmi.b www
- | is coded by
- | .word 0x4a68,0xfff0,0x6bfa | test
- !
- .text; .even
-
- .globl _frexp
- !
- tstl sp@(4) | 1st arg == 0 ?
- bne nonzero
- tstl sp@(8)
- --- 169,179 ----
- | bmi.b www
- | is coded by
- | .word 0x4a68,0xfff0,0x6bfa | test
- !
- .text; .even
-
- .globl _frexp
- !
- tstl sp@(4) | 1st arg == 0 ?
- bne nonzero
- tstl sp@(8)
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/ldexp.cpp,v
- retrieving revision 1.6
- diff -c -r1.6 ldexp.cpp
- *** 1.6 1992/10/09 20:35:29
- --- ldexp.cpp 1993/05/29 20:28:46
- ***************
- *** 42,47 ****
- --- 42,48 ----
- | #2 added support for denormalized numbers -kub-, 01/90
- | #3 ported to gcc ++jrb 04/90
- | #4 handle exponent overflow when ints are 32 bits -kub-, 04/90
- + | #5 make returned zero signed mj, 05/93
- |-----------------------------------------------------------------------------
-
- lea sp@(4),a1
- ***************
- *** 49,64 ****
-
- movew a1@,d0 | extract value.exp
- movew d0,d2 | extract value.sign
- lsrw #4,d0
- - andw #0x7ff,d0 | kill sign bit
-
- ! andw #0x0f,a1@ | remove exponent from value.mantissa
- ! tstw d0 | check for zero exponent - no leading 1
- ! beq 0f
- ! orw #0x10,a1@ | restore implied leading 1
- ! bra 1f
- ! 0: addw #1,d0
- ! 1:
- #ifdef __MSHORT__
- addw a1@(8),d0 | add in exponent
- extl d0
- --- 50,66 ----
-
- movew a1@,d0 | extract value.exp
- movew d0,d2 | extract value.sign
- + bclr #15,d0 | kill sign bit
- lsrw #4,d0
-
- ! moveq #0x0f,d3 | remove exponent from value.mantissa
- ! andb d2,d3 | four upper bits of value in d3
- ! bset #4,d3 | implied leading 1
- ! tstw d0 | check for zero exponent
- ! bne 1f
- ! addqw #1,d0
- ! bclr #4,d3 | nah, we do not need stinkin leadin 1
- ! 1: movew d3,a1@ | save results of our efforts
- #ifdef __MSHORT__
- addw a1@(8),d0 | add in exponent
- extl d0
- ***************
- *** 68,74 ****
- #endif
- cmpl #-53,d0 | hmm. works only if 1 in implied position...
- ble retz | range error - underflow
- ! cmpl #2047,d0
- bge rangerr | range error - overflow
-
- clrw d1 | zero rounding bits
- --- 70,76 ----
- #endif
- cmpl #-53,d0 | hmm. works only if 1 in implied position...
- ble retz | range error - underflow
- ! cmpl #0x7ff,d0
- bge rangerr | range error - overflow
-
- clrw d1 | zero rounding bits
- ***************
- *** 77,89 ****
-
- retz:
- moveq #0,d0 | zero return value
- ! moveq #0,d1
- jra L0
-
- rangerr:
-
- #ifdef ERROR_CHECK
- ! moveq #ERANGE,d0
- Emove d0,Errno
- pea pc@(_Overflow) | for printf
- pea Stderr |
- --- 79,93 ----
-
- retz:
- moveq #0,d0 | zero return value
- ! movel d0,d1
- ! lslw #1,d2 | transfer argument sign
- ! roxrl #1,d0
- jra L0
-
- rangerr:
-
- #ifdef ERROR_CHECK
- ! moveq #Erange,d0
- Emove d0,Errno
- pea pc@(_Overflow) | for printf
- pea Stderr |
- ***************
- *** 92,101 ****
- #endif ERROR_CHECK
-
- moveml __infinitydf,d0-d1 | return HUGE_VAL (same as in <math.h>)
- ! andw #0x8000,d2 | get sign bit of argument
- ! swap d2
- ! clrw d2
- ! orl d2,d0
- L0:
- moveml sp@+,d2-d7 | pop saved reggies
- rts
- --- 96,104 ----
- #endif ERROR_CHECK
-
- moveml __infinitydf,d0-d1 | return HUGE_VAL (same as in <math.h>)
- ! tstw d2
- ! bge L0
- ! bset #31,d0
- L0:
- moveml sp@+,d2-d7 | pop saved reggies
- rts
- ***************
- *** 201,212 ****
- error_plus:
- swap d0
- moveml d0-d1,a7@- | print error message
- ! moveq #ERANGE,d0 | Overflow: errno = ERANGE
- Emove d0,Errno
- pea pc@(_Domain) | for printf
- bra error_exit |
- error_nan:
- ! moveq #EDOM,d0 | NAN => errno = EDOM
- Emove d0,Errno
- moveml a0@(24),d0-d1 | result = +inf
- moveml d0-d1,a7@- | print error message
- --- 204,215 ----
- error_plus:
- swap d0
- moveml d0-d1,a7@- | print error message
- ! moveq #Erange,d0 | Overflow: errno = ERANGE
- Emove d0,Errno
- pea pc@(_Domain) | for printf
- bra error_exit |
- error_nan:
- ! moveq #Edom,d0 | NAN => errno = EDOM
- Emove d0,Errno
- moveml a0@(24),d0-d1 | result = +inf
- moveml d0-d1,a7@- | print error message
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/modf.cpp,v
- retrieving revision 1.2
- diff -c -r1.2 modf.cpp
- *** 1.2 1992/10/09 20:35:29
- --- modf.cpp 1993/05/29 20:28:48
- ***************
- *** 1,18 ****
- #if !defined (__M68881__) && !defined (sfp004)
-
- | take floating point to integer and fractional pieces
- ! |
- | C interface
- | double modf( double value, double *iptr)
- | returns fractional part of value
- | in *iptr returns the integral part
- | such that (*iptr + fractional) == value
- ! |
- |-----------------------------------------------------------------------------
- | ported to 68000 by Kai-Uwe Bloem, 12/89
- | #1 original author: Peter S. Housel 9/21/88,01/17/89,03/19/89,5/24/89
- | #2 replaced shifts by swap if possible for speed increase -kub-, 01/90
- | #3 ported to gcc ++jrb 03/90
- |-----------------------------------------------------------------------------
-
- BIAS8 = 0x3ff - 1
- --- 1,20 ----
- #if !defined (__M68881__) && !defined (sfp004)
-
- | take floating point to integer and fractional pieces
- ! |
- | C interface
- | double modf( double value, double *iptr)
- | returns fractional part of value
- | in *iptr returns the integral part
- | such that (*iptr + fractional) == value
- ! |
- |-----------------------------------------------------------------------------
- | ported to 68000 by Kai-Uwe Bloem, 12/89
- | #1 original author: Peter S. Housel 9/21/88,01/17/89,03/19/89,5/24/89
- | #2 replaced shifts by swap if possible for speed increase -kub-, 01/90
- | #3 ported to gcc ++jrb 03/90
- + | #4 replaced by a completely new, smaller and faster implementation,
- + | Michal Jaegermann, ntomczak@vm.ucs.ualberta.ca - 05/93
- |-----------------------------------------------------------------------------
-
- BIAS8 = 0x3ff - 1
- ***************
- *** 21,104 ****
- .globl _modf
- _modf:
- lea sp@(4),a0 | a0 -> float argument
- - movel sp@(12),a1 | a1 -> ipart result
- moveml d2-d7,sp@- | save d2-d7
-
- ! movew a0@,d0 | extract value.exp
- ! movew d0,d2 | extract value.sign
- ! lsrw #4,d0
- ! andw #0x7ff,d0 | kill sign bit
- !
- ! cmpw #BIAS8,d0
- ! bge 1f | fabs(value) >= 1.0
- !
- ! clrl a1@ | store zero as the integer part
- ! clrl a1@(4)
- ! moveml a0@,d0-d1 | return entire value as fractional part
- ! jra L0
-
- 1:
- ! cmpw #BIAS8+53,d0 | all integer, with no fractional part ?
- ! blt 2f | no, mixed
-
- ! movel a0@,a1@ | store entire value as the integer part
- ! movel a0@(4),a1@(4)
- moveq #0,d0 | return zero as fractional part
- ! moveq #0,d1
- ! L0:
- ! moveml sp@+,d2-d7 | restore saved d2-d7
- ! rts
- 2:
- ! | moveml d3-d7,sp@- | save some registers (d2 is pushed already)
- ! moveml a0@,d4-d5 | get value
- !
- ! andl #0x0fffff,d4 | remove exponent from value.mantissa
- ! orl #0x100000,d4 | restore implied leading "1"
-
- ! moveq #0,d6 | zero fractional part
- ! moveq #0,d7
- 3:
- ! cmpw #BIAS8+37,d0 | fast shift, 16 bits ?
- ! bgt 4f
- ! movew d6,d7 | shift down 16 bits
- ! movew d5,d6
- ! movew d4,d5
- ! clrw d4
- ! swap d7
- ! swap d6
- ! swap d5
- ! swap d4
- ! addw #16,d0
- ! bra 3b
- 4:
- ! cmpw #BIAS8+53,d0 | done ?
- ! bge 5f
- ! lsrl #1,d4 | shift integer part
- ! roxrl #1,d5
- !
- ! roxrl #1,d6 | shift high bit into fractional part
- ! roxrl #1,d7
- !
- ! addw #1,d0 | increment ipart exponent
- ! bra 4b | keep shifting
- ! 5:
- ! | normalize ipart (all values are in correct reggies)
- ! | save a1, save d2-d7 that norm_df will pop
- ! movel a1,sp@-
- ! pea L1 | set up return address
- ! moveml d2-d7,sp@- | norm_df will pop this
- ! clrw d1
- ! jmp norm_df | go do it
- ! L1: | norm_df will rts to here
- ! movel sp@+,a1 | pop saved a1
- ! moveml d0-d1,a1@ | store result into ipart
- !
- ! | norm fractional part
- ! movel d6,d4 | get frac into d4/d5
- ! movel d7,d5
- clrw d1 | rounding = 0
- ! movew #BIAS8-11,d0 | set frac part exponent, sign already in d2
- ! jmp norm_df | norm_df will pop d2/d7 we save before
- | it will return to our caller via rts
- | with result in d0-d1
-
- --- 23,88 ----
- .globl _modf
- _modf:
- lea sp@(4),a0 | a0 -> float argument
- moveml d2-d7,sp@- | save d2-d7
- + moveml a0@+,d0-d1
- + movel a0@,a1 | a1 -> ipart result
-
- ! movel d0,d2 | calculate exponent
- ! swap d2
- ! bclr #15,d2 | kill sign bit
- ! lsrw #4,d2 | exponent in lower 12 bits of d2
- !
- ! cmpw #BIAS8,d2
- ! bgt 1f | fabs(value) >= 1.0
- ! | | return entire value as fractional part
- ! clrl a1@+ | d0, d1 already ok
- ! clrl a1@ | make integer part 0
-
- + 0:
- + moveml sp@+,d2-d7 | restore saved d2-d7
- + rts
- +
- 1:
- ! movew #BIAS8+53,d3
- ! subw d2,d3 | compute position of "binary point"
- ! bgt 2f | branch if we do have fractional part
-
- ! moveml d0-d1,a1@ | store entire value as the integer part
- moveq #0,d0 | return zero as fractional part
- ! movel d0,d1
- ! jra 0b
- 2:
- ! movel d1,d5 | save for computation of fractional part
-
- ! moveq #32,d6
- ! cmpw d6,d3
- ! blt 3f | jump if "binary point" in a lower part
- ! movel d0,d4
- ! subw d6,d3
- ! moveq #0,d6 | compute mask for splitting
- ! bset d3,d6
- ! negl d6
- ! andl d6,d0 | this is integer part
- ! moveq #0,d1
- ! notl d6
- ! andl d6,d4 | and denormalized fractional part
- ! jra 4f
- 3:
- ! moveq #0,d6 | splitting on lower part
- ! bset d3,d6
- ! negl d6
- ! andl d6,d1 | this is integer part
- ! moveq #0,d4 | nothing in an upper fraction
- ! notl d6
- ! andl d6,d5 | and clear those unneded bits
- 4:
- ! moveml d0-d1,a1@ | store computed integer part
- !
- ! swap d0
- ! exg d0,d2 | set registers for norm_df
- clrw d1 | rounding = 0
- ! | | normalize fractional part
- ! jmp norm_df | norm_df will pop d2/d7 we saved before
- | it will return to our caller via rts
- | with result in d0-d1
-
- ***************
- *** 109,115 ****
- | manually optimized by Michael Ritzert
- |
- | double modf( double X, double * IP )
- ! |
- | 30.11.92
- | ritzert@dfg.dbp.de
- |
- --- 93,99 ----
- | manually optimized by Michael Ritzert
- |
- | double modf( double X, double * IP )
- ! |
- | 30.11.92
- | ritzert@dfg.dbp.de
- |
-